Download

Rotating an object around the character with the right stick?

Hey guys. I’m trying to figure out this rather unique conundrum. I’m trying to orbit an object around the player using the right stick as depicted here:

However, I am trying to get it to a point where the right stick’s “forward” is the same as the player’s “forward.” Right now, however, when the player turns left and the player then hits forward on the right analog stick, then the object goes out to the player’s right, rather than properly forward, as depicted here:

Does that make sense? I’d like it so that when you hit forward on the right stick, the object goes out in front of the player, no matter the player’s direction.

Here’s my current code:

Just as a note, I’m making a third person game. Not a top-down, twin-stick shooter.

Thanks, everybody!

I set up this blueprint to keep the ball in front of the player, but you can change it to rotate your whole rotational system.


but then after I realized you might be able to just add the rotation of the player to the rotation of your whole rotational system.

You can rotate the local offset vector (the length 500 one) by the actor’s world rotation and then add it to the actor’s world position. That should definitely work. See the RotateVector node.

Alternatively, try getting the actor’s transform and transform the local offset vector. That does the rotation, translation and scale in one step.

Another thing is to consider attaching the ball to the actor. It will automatically move with the actor and you can set its relative location, which is in the actor’s coordinate space. So after attaching, SetRelativeLocation(500, 0, 0) would set the ball to be in front of the actor no matter how he turns.