Make Pawn move according to Camera orientation

Greetings, everyone.

So, I’m making a roller platformer in UE4, and I have keyboard and joystick input to move the sphere, but I also want to include the mouse and right analog sticks to control the camera looking at the ball. I’ve configured everything for the camera rotate around the ball (which is a Pawn) without being affected by the ball’s roll, yaw and pitch rotation’s values, but even if I rotate the camera, the ball always has the same direction when moving, meaning that if I press forward, and rotate the camera, the ball always has the same direction.

How can I manage to make the camera change its direction according to where the camera is looking? I think this is the same principle as Orient Rotation to Movement regarding Characters, but as I’m dealing with a Pawn, I can’t manage to find anything like that.

SCREENSHOTS

Movement Input Logic

Camera Input logic

Camera Settings

Spring Arm Settings

Hey there,

I assume your Camera uses the Control Rotation ?

If yes, then try to use the Control Rotation for your Ball. Set his YAW etc to the Control Rotation
ones.

If not, you should probably think about adding the Control Rotation to your logic.

I can’t go into more detail, since i don’t know you actual setup.

If you have trouble, please add screenshots of your Settings, the Input Logic and the Camera Movement Logic. Then i can see what you are doing and maybe guide you in the correct direction.

Cheers! (:

Try the following math…

Get the forward vector of the camera, and the forward vector of the ball.
Lerp between these values, using a scalar value in the Alpha parameter to get a “Target Vector”.
Finally, multiply this target vector by the speed at which the ball is currently travelling (or slightly less, for a more realistic feel).

This will smoothly create a new position between where the ball is currently rolling toward, to where the camera is telling the ball it should be rolling toward.

Alternatively, you can try using Rotation vectors instead, and just change the ball’s Yaw to match the camera’s (perhaps also with linear interpolation to smooth it out)…

If the issue is that you are manually rotating the ball as it moves, perhaps you should consider making the ball a child component to a default scene node. Then, instead of rotating the entire pawn, only rotate the ball mesh, keeping its parent in the same upwards orientation as the camera.

I don’t seem to use any Control Rotation on my Camera.

As I’m having trouble implementing the desired system, I’ve proceeded to add the requested screenshots. See above!

And thanks for the help!

Hey, everyone! So, after some research, I’ve accidentally found the solution in my problem in a topic about the Camera Spline functionality. So, basically, you have to make a rotate vector (RotateVector) based upon the vector generated from the product of the axis value and the defined speed, and a rotator created from the Yaw/Z of the CameraRotation of the PlayerCameraManager. After that, add that to an AddForce or AddTorque node, and the Pawn will go where the camera is rotating.

Here is a screenshot of the logic:

You then just need to differ between X and Y regarding forward/backward and sideways movement!