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"

Help with twin-stick character rotation

I've got a twin stick shooter character and a level filled with static cameras placed in the world. I can't figure out how to set my characters rotation (where he is aiming basically) to be relative to the camera's rotation instead of the controller rotation. In the image I show my current setup, which works fine using an attached camera or a camera with the same starting rotation. So how can I set up the rotation to take into account the camera actors location?alt text

Product Version: UE 4.19
rotationexample.jpg (459.3 kB)
more ▼

asked Jul 01 '18 at 07:34 PM in Blueprint Scripting

avatar image

Malibu Lizard
17 3 8 8

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

1 answer: sort voted first

Create a new project using the third person character template. This example has the blueprints and character movement settings that let you move where the thumbstick points, regardless of the camera angle.

more ▼

answered Jul 01 '18 at 09:19 PM

avatar image

3.8k 18 23 20

avatar image Malibu Lizard Jul 01 '18 at 10:11 PM

Movement isn't the issue, rotation is. Movement is fine. Okay but how can I translate the third person templates rotation setup to a top down perspective using a camera not connected to the character on a stick but instead static in the world?

avatar image mightyenigma Jul 02 '18 at 02:39 AM

wait. I dont understand yet. So what kind of movement are we talking about here? I thought you wanted it to go directly in the direction the thumbstick is moved without having the player turn to face that direction first. That's not what you meant?

avatar image Malibu Lizard Jul 02 '18 at 02:54 AM

No, movement is fine, movement is working as expected, rotation is not. The character moves in the direction of the keypad/thumbstick relative to the current static camera. Rotation, i.e looking in the direction of the other thumbstick/mouse is not currently relative to camera. I've got the movement done, I need the rotation- where the character is looking/aiming not where the character is moving. The image I posted shows my current setup for rotation, which works fine but isn't relative to the current camera view, meaning that if my character swaps camera view to one thats say, rotated 180 degrees, then all the pawn rotation is backwards and gets very messed up. My level is made up of different sections each with their own static camera thats not connected to the character- I need my rotation to respect the changing camera view. So aiming north, East, South or west is always decided from the perspective of the current camera. Does that make more sense?

avatar image mightyenigma Jul 02 '18 at 01:38 PM

Yes it is clearer now. What have you tried so far which involves the camera's forward vector?

avatar image Malibu Lizard Jul 02 '18 at 04:23 PM

I suck at math, so not much. I use the cameras forward and right vectors to help with movement but have no idea how to add them into my rotation.

avatar image mightyenigma Jul 02 '18 at 05:56 PM

Sorry I'm not great at rotation vectors either, so I'm not sure how to approach this problem myself. But I have an idea that maybe your current code in the screenshot is assuming the camera is lined up with the player, so maybe all we have to do is get the camera's Forward Vector and then GetRotationFromXVector from that, and add the result to the GetRotationFromXVector you already have, and feed THAT into the Target of the RInterpTo. Sorry I don't know if this will work but that's what I would try next in your situation.

avatar image Malibu Lizard Jul 02 '18 at 07:20 PM

I get what you mean, I've been thinking the same thing myself, I just don't know how to implement that. I don't know if im adding, multiplying or subtracting vectors or where I should adding these nodes. I'm totally fine with starting the rotation again from scratch but again, don't know how to implement what I need.

avatar image Surya Sel Jul 02 '18 at 07:58 PM

Have you tried "Get Hit Result Under Cursor" node by any chance?

avatar image Malibu Lizard Jul 02 '18 at 08:01 PM

Not because I don't understand what that node would do when the player is using a thumbstick or keyboard as opposed to a mouse cursor.(I assume by cursor that what it means) I wanted something that works with any control scheme.

avatar image Surya Sel Jul 02 '18 at 08:10 PM

A'ight, then you can spawn a "Crosshair" Actor on the floor and move it along the plane according to your device input. And then get the Character to look at it at every tick.

avatar image Malibu Lizard Jul 02 '18 at 08:16 PM

So you suggest I create a Crosshair actor, and use that to set the characters rotation? In theory that sounds great but I am not great at programming yet and that sounds like it would be harder to implement that finding a way to align my inputs with the cameras forward vector. Would that not just lead to the same issue but in the crosshair actor instead, as that would need to rotate/move based on the input from the camera actors perspective?

avatar image Surya Sel Jul 02 '18 at 08:22 PM

Pardon me if I've misunderstood you by any chance, but can't you repeat "The character moves in the direction of the keypad/thumbstick relative to the current static camera" for the crosshair too with identical logic mapped to the other "thumbstick" (or whatever you want)? Then it's just a matter of getting the character to face the crosshair, right?

avatar image Malibu Lizard Jul 02 '18 at 08:44 PM

alt text This is my simple movement set up right now. I'm not sure how that would translate into a cross hair actor. I don't really want a cross hair to be able to be anywhere on the screen but assuming it was an invisible actor wouldn't it cause issues still? Like wouldn't that make the 'speed' of the rotation depend on how close the cross hair actor is too? Like if the cross hair actor was far away the player would rotate slowly and if it's close the actor would rotate super fast etc rather then at a constant speed? Also what if the player didn't rotate at all for a while and ran in a straight line for a few minutes leaving the crosshair actor way behind, then rotation would be painfully slow? I appreciate your trying to help but I don't think I understand what your suggesting :S

untitled-1.jpg (453.8 kB)
avatar image Surya Sel Jul 03 '18 at 04:13 PM

Oh, alright so that's the kinda control you're lookin' at. Did you try adding the Current Cam's Yaw to the Yaw of your XY-derived rotation before setting it as the Control Rotation? (Try Yaw or Roll, I think one of them should work out)

avatar image Malibu Lizard Jul 04 '18 at 05:18 PM

alt text This is my new setup, and for now this seems to be working for me personally without issue. Hopefully this is a correct method and maybe this will help someone else out with a similar issue. Thank you everyone for your replies and help.

untitled-1.png (386.8 kB)
avatar image mightyenigma Jul 05 '18 at 04:31 PM

Oh nice. I didn't know about the Rotatevector node

(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