Learning interfaces. Is my attempt an acceptable use?

I have a player character and a ball actor. If the player is facing the ball and is within a certain distance of it then I want to update the position of the ball to “stick” to the forward vector of the player. When the player moves, so does the ball by the players feet.

So, I thought I would use an interface to pass a vector from the player blueprint to the ball.

It works but before I go any further I need to know if this is a legit way of doing it?

Is it ok to do this on the tick (I couldn’t think of another way)? Is it expensive to use GetActorOfClass on tick?

You only need to get the reference to the ball once. From then on, you can just use the variable. You are using the interface correctly. :slight_smile:

It would be a bit better if you could get an actor reference to the ball. At the moment, you know it’s class, and interfaces can just talk to an actor.

You could use an actor tag for that, with the node ‘get all actors with tag’, to find the ball ( not on tick ).

Hi, thanks for the reply.
Would promoting a reference to a variable produce a hard reference? Ideally, I am trying to avoid this (this is why I keep getting the reference in the tick).

1 Like

You already have a hard ref because you’re mentioned the class in the get actors node.

That’s why I say use actor tags, you can still find the actor, get a reference and talk to it, but no class is ever mentioned.