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"

Why doesn't my character turn when moving

I have set up tank controls (w moves forward, s moves backwards and a and d turn left and right). However when I press either w or s together with a or d the character goes straight. In other words when I run forwards of backwards the character doesn't turn. But when I press a or d when stationary my turning works fine.

I've attached screenshot of my blueprint. I've paintbrushed some uninteresting parts to make it easier to read: https://i.imgur.com/Mln0dCD.png

Basically I have set up an switch_on_int so I can have different turning speed for left and right. The first branches can be ignored, they don't do anything.

Product Version: UE 4.18
Tags:
more ▼

asked Jan 13 '18 at 05:54 AM in Using UE4

avatar image

tatulux
7 6 6 12

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

1 answer: sort voted first

If your character uses a movement component, you have to use its functions to control the movement. The functions are Add Movement Input and Add Controller Yaw Input for the linear movement and rotations respectively.

Your rotation uses SetActorRotation though, which may conflict with how the movement component handles it. You should use Add Controller Yaw Input instead.

Make also sure you check Use Controller Rotation Yaw in the Details panel of your character blueprint.

more ▼

answered Jan 13 '18 at 10:51 AM

avatar image

vr_marco
2.2k 10 6 12

avatar image tatulux Jan 13 '18 at 11:52 AM

Thanks for the response!

If I turn on "Use Controller Rotation Yaw" then the character rotates with the camera I think? I don't want that. I want character that turns with a and d on keyboard and camera is controlled by mouse and each can point to different directions. I'll check those other things you mentioned next.

Other thing I noticed is that when I walk backwards the character gets jittery but that has probably nothing to do with these things.

It is weird how both the movement forwards/backwards and turning work independently but not at the same time?

avatar image vr_marco Jan 13 '18 at 11:58 AM

What the camera does when you turn depends on how the camera is rigged to your pawn. There are options on the camera spring arm to have it follow or not the pawn's yaw rotation. Have a look.

As said, stick to the functions provided by the movement component. They do work at the same time. Another thing to check is how you set "Orient Rotation to Movement" inside the movement component.

avatar image tatulux Jan 14 '18 at 06:28 AM

Thanks for the response! (For some reason my response did not get through so I'm writing it again.)

I changed all my stuff to basics: https://i.imgur.com/xUjr9qW.png

Now it works but not quite well.

Basically my issue now is that I can not change the rotation speed of the character in blueprint. When stationary the character rotates way too fast and when moving and turning it is lower. I noticed that when I adjusted my axis input scales for a and d in project settings/input (from 1.0 to much smaller values) it changes the rotation speed when moving. But stationary it is too fast and I can't change it. I really need precise control of the rotation speeds for my project though.

So my questions are: 1. How do I control the rotation speed of my character? 2. Why the input scale changes rotation speed only when moving? 3. Why do my turninig speed variables do not work (LefRotSpeedLeft and -Right)?

In the first pic you can see how I've set up the movement. ere you can see how I define those variables I want to use for ration speed: https://i.imgur.com/FyYFyGS.png I should move them to correct place at some point but I want to keep things simple before I move stuff to other blueprints.

avatar image vr_marco Jan 14 '18 at 10:21 AM

You are using the wrong input function for the turn. It should be Add Controller Yaw Input not Add Movement Input, unless you want your character to slide right/left instead of turning.

avatar image tatulux Jan 14 '18 at 12:12 PM

If I use the add controller yaw my character is turned with my mouse which is not what I want. I want to control the camera view the mouse and the character with keyboard.

avatar image vr_marco Jan 14 '18 at 12:33 PM

Check how your inputs are mapped in Project Settings --> Input. This is what determines which keys/device is used for each event. If you want the turn to happen with keys you have to map the turn events to those keys.

avatar image tatulux Jan 14 '18 at 01:36 PM

Thank you! I feel so stupid now :D. I checked my inputs and you are right. I think there was a duplication for the mouse X there. So ... made some changes and I got the character rotation to work now. Seems like it works ok.

I broke my view mouse controls though which I'd guess need to be done differently now because my mouse yaw was previously using the addControllerYaw node.

avatar image vr_marco Jan 14 '18 at 06:22 PM

To rotate your camera view you need to rotate the spring arm. See how this is done in the third person character template.

avatar image tatulux Jan 15 '18 at 02:07 PM

Thanks for the response again!

I changed everything back to normal instead of trying to experiment. It basically works but not really. When turning when stationary the charcter yaws way too fast. When moving the turning speed is okayish. But it is different when moving and when stationary. All I can do is go to project settings and reduce the scale of the turning inputs from 1.0 to something like 0.05 which for some reason only adjusts the rotation speed when moving???

And I can't change any of it in blueprint. When stationary it still rotates like 360degrees per second. When pressing w and a/d together the rotation speed is controlled by the axis input scale. For my project it is crucial that I can adjust the turning speed exactly.

Here is how I have now set up my movement. For some reason the multipliers do nothing? Even if the movement node expects a range of -1...1 it should become slower with value of 0.1 instead of 1? https://i.imgur.com/xUjr9qW.png

I have set those variables up in the same blueprint like this. I have lots of stuff in that eventbeginplay, maybe I should move some of it elsewhere? https://i.imgur.com/FyYFyGS.png

I'd be super glad if for any more help you could give. How do I control rotation speed? Once I get it to work I think I can add all the other fine tuning stuff myself.

avatar image vr_marco Jan 15 '18 at 03:56 PM

Any chance you can share your project for me to have a look? Look me up on the Forums (not AnswerHub but the Unreal Engine forum) and send me a private message if you like.

avatar image vr_marco Jan 15 '18 at 03:58 PM

Or on Discord with my nickname.

(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