Make Pawn move according to Camera orientation
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.
Movement Input Logic Camera Input logic Camera Settings Spring Arm Settings
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!
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.
answered Apr 18 '16 at 12:37 PM
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
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here