I think using a Pawn instead of an Actor would be better. Since it has this functionality (MoveTo).
Or you can use parenting / attach one actor to another.
Thanks! Parenting/attach sounds like it is what i want. I will look into that. For the sake of argument though, is there a way to add c++ functions to the tick event?
Whilst itemA and itemB are declared for the ‘FollowActor’ function, they are not declared for the ‘Tick’ function. Somewhere, you would need a declaration of: -
AStaticMeshActor* itemA
AStaticMeshActor* itemB
If you do this within the ‘Tick’ function, then you would also need some extra code to get the actors you want to move as the code above would be ‘null’. Alternatively, you can put this in the header file. If you’ve created your actors within this class, then this is probably the easiest. However, if you did do this, you need to change the names of ‘itemA’ and ‘itemB’ within the ‘FollowActor’ function as they would clash with the header declared variables; maybe call them ‘Leader’ and ‘Follower’.
Did you use foreward declaration in the header file? Like
class AStaticMeshActor;
If yes, then you have to include “StaticMeshActor.h” in the CPP file or the compiler doesn’t recognize the Object.
Or are itemA and itemB no member-variables of the parent Class? Than the previous answer should be right.