Getting Location of an actor from a different class

Hello,

Problem: I am trying to get the location of an actor from a character.

Setup of the Character Hierarchy called TPC_TEST2, parent class is Character:

271503-character.png

Setup of the Actor Hierarchy called Ball_BP, Parent Class is Actor:

271504-actor.png

BallSphere is a static mesh. Is there any way for TPC_TEST2 to access the location of any instance of Ball_BP?

Ofcorse, there many ways to do this and you need to pick right one to do this efficiently.

Can you describe how those actors will interact in your gameplay?

Thank you for your response.

As for how they interact, the Blade portion of the character needs to react to the position of the ball. Where I first ran into the issue is when I tried to use LineTraceForObjects. I can access the location of the blade just fine:

271506-linetrace.png

but where I want to plug in my end point I do not know how to get the Ball position.

I want to trace a line between the blade and the ball at all times. I need to know the ball location so that I can adjust the rotation of the blade.

You can get the ball location when the blade overlaps it or depending on your scenario not sure if you are checking to see IF the blade hit a ball, then in that case you could just line trace out from the blade to a position maybe 500 units in the forward direction of the blade or whatever and see if it hit a ball. How is this line trace being used exactly?

yes, just one.

If you only have one ball this is relatively easy. You simply need to give your blade or the parent actor of the blade a reference to the ball. Depending on whether the ball is spawned into the world or exists from the start will determine how best to get this reference. Check out video #25 I explain various ways to create references to objects. I think one of them should work well for this situation.

Do you only have single ball during gameplay?

Awesome, thank you. This video helped me solve my problem. Here is the solution I ended up using:

Glad it helped.