The problem in your script is that you are casting the action itself as an IMovable instead of the agent. Furthermore you can use the IMovable interface type as the AgentType so that the whole action becomes smaller and reusable in case you want to override the agent. Specifying AgentType to be type of IMovable means that the agent needs to have an IMovable component since thats all that the action needs to work. Here is the script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
usingUnityEngine;
usingNodeCanvas;
usingNodeCanvas.Variables;
usingApex;
usingApex.Steering;
namespaceNodeCanvas.Actions{
[Category("Apex")]
[AgentType(typeof(IMovable))]
publicclassApexMoveTo:ActionTask{
[RequiredField]
publicTransform target;
protectedoverridevoidOnExecute(){
(agent asIMovable).MoveTo(target.position,false);
EndAction();
}
}
}
Cheers
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.