Download

How to make direct communication between two different Pawn actors in the world?

I have a Cannon pawn actor with a movable Target pawn actor. I wanted to make the Target return a vector of its Location to the Cannon.

I would like to have direct communication between the Cannon and the Target, so that the Target will be able to return a vector location to the Cannon. Something similar to:



FVector TargetLocation = Cannon->GetTargetPawn()->GetTargetLocation();


But I am not sure how to instantiate the Target class in the Cannon. Do you require UPROPERTY() for the Target pawn variable in the Cannon class? I know actors and actors do not have hierarchical relationships, not like actors and components of other actors.

I looked at the QuickStart C++ and FPS C++ tutorials, but it doesn’t cover direct communications between two different actor classes in C++.

If I am mistaken, please let me know. Thanks in advance.