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"

How can I rotate the camera around the player using the right virtual joystick?

I am attempting to get player control with the left virtual joystick and I would like to be able to spin the camera around the player with the right joystick. This is all being done in the ball rolling example map. How would I go about controlling the camera with the right stick but still constraining it to the same distance from my character and always keeping my character centered within the camera view? Thanks.

Product Version: UE 4.10
more ▼

asked Dec 31 '15 at 05:04 PM in Blueprint Scripting

avatar image

190 35 29 54

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

1 answer: sort voted first

Hi Anaklosmos,

Since the PhysicsBallBP Pawn in the Rolling template is already using a SpringArm component to maintain the distance between Ball and Camera, this is a pretty easy thing to implement. You'll notice that the Transform of the SpringArm component is set to AbsoluteRotation. By changing the Z to 90, you'll see it has maintained the distance between the camera and ball components, but rotated to face the ball from another direction.

The easiest way to set this up is by adding another Input to turn the camera (Edit > Project Settings > Input) as follows:

alt text

Then, in the Event Graph for the PhysicsBallBP, add the following: alt text

This will take the Axis input from the Right Thumbstick (-1 to 1) and add rotation to the Spring Arm. This occurs on tick, so it's a nice smooth movement, but you can adjust this by multiplying or dividing the Axis Value before plugging it into the Make Rotator Z input.

Hope that helps!

turnballcam.png (62.2 kB)
more ▼

answered Dec 31 '15 at 10:57 PM

avatar image Anaklosmos Jan 01 '16 at 07:27 AM

This setup works, however, it does not update the ball controls to the direction in which the camera is facing. Ex. When I rotate 90 degrees clockwise, and push up on the virtual joystick, expecting the ball to roll forward in relation to the camera view, it will roll left. Simply put, the controls stay consistent when they should be updated based on the camera view. How can I fix this so that the ball will always roll the correct direction in relation to the camera and the joystick? Thanks

avatar image Ben Halliday STAFF Jan 02 '16 at 11:24 PM

Ah, okay, in that case you also need to rotate the vector you're using for Torque to match the Spring Arm's new rotation. It should look like this:

alt text

You'll want to do the same for the Roll Forwards/Backwards controls.

rotatevector.png (90.8 kB)
avatar image Anaklosmos Jan 03 '16 at 05:33 AM

Awesome! That worked perfectly! Thanks so much!

avatar image somethingstarted Jun 25 '16 at 08:55 AM

what is that node with the X that attaches from InputAxis > ??? >> Make VEctor?

avatar image Sean L ♦♦ STAFF Jul 11 '16 at 05:29 PM

It's a multiplication node. Type in the * to access it in blueprints.

avatar image tonycapp21 Sep 03 '18 at 03:39 AM

Sorry to ask, but using that same layout I cant seem to get my forward/backward controls to work. Is there anything different or is it completely identical to the right/left? Right/left works perfectly.


avatar image Swag Surgin Oct 19 '18 at 01:42 AM

Just do the Same to the the Roll Forwards/Backwards.

I just copied and pasted the GetWorldRotation, and Rotate Vector, and connected it up like my picture. If you cant get it to work, just reply! alt text

(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