x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 Movement Input Logic Camera Input logic Camera Input logic Camera Settings Camera Settings Spring Arm Settings Spring Arm Settings

Product Version: UE 4.11
Tags:
more ▼

asked Apr 18 '16 at 12:00 PM in Blueprint Scripting

avatar image

RicSousa27
5 3 4 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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:

alt text

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

more ▼

answered May 02 '16 at 12:33 PM

avatar image

RicSousa27
5 3 4 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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! (:

more ▼

answered Apr 18 '16 at 12:37 PM

avatar image

eXi
6.8k 333 185 470

avatar image RicSousa27 May 02 '16 at 11:16 AM

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Apr 18 '16 at 12:59 PM

avatar image

MichaelWion
250 29 40 50

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question