Forums › 💬 NodeCanvas › 🗨️ General Discussion › Implement two interfaces in action class › Reply To: Implement two interfaces in action class
Hey,
Sorry for late reply.
So, I don’t have APEX so the following code might not work as is, but you will get the idea of how you can go about it.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
using UnityEngine; using NodeCanvas; using NodeCanvas.Variables; using Apex.Steering; using Apex.Messages; using Apex.Services; namespace NodeCanvas.Actions{ [Category("Apex")] [AgentType(typeof(IMovable))] public class ApexMoveTo : ActionTask, IHandleMessage<UnitNavigationEventMessage> { [RequiredField] public Transform target; protected override string OnInit(){ GameServices.messageBus.Subscribe(this); return null; } protected override void OnExecute(){ (agent as IMovable).MoveTo(target.position, false); } public void Handle(UnitNavigationEventMessage message){ switch(message.eventCode){ case UnitNavigationEventMessage.Event.DestinationReached: { EndAction(true); break; } case UnitNavigationEventMessage.Event.StoppedDestinationBlocked: { EndAction(false); break; } } } } } |
As for the errors you are getting:
1. As the error says, you are declaring blackboard which already exists (it’s inherited from Task). You can use the inherited blackboard directly without the need to declare a new one unless the blackboard you want to use is not the agent’s one, in which case you should give it another name.
2. Well the second is also simple. You need to implement the interface member 🙂
The _MonoManager issue has been fixed in the new version. Sorry about that.
Let me know if it works for you.
Cheers
