Hello all, im working on making a top top shooter and ive managed to get the rotation working. The problem is that ive tried to now inplement moving with w,a,s,d and as soon as i try to move it breaks my rotation blueprint. On top of that the movement does not work correctly. It doesnt move according the the characters direction. Does anyone have any insights?
You don’t need two Add Movement Input
nodes (And even if you had two nodes, there still wouldn’t be any need for the Sequence
node) and can just recombine the struct pins of the action values and plug the action value vector into the world direction pin.
You have nothing to do with the control rotation in this case.
Click on the movement component under the Components window (that should be on the top left by default), navigate to the Details window (on the top right) while it’s selected, and enable the Orient Rotation to Movement setting. Though if you want that, you’d also wanna disable the character facing to the mouse while it’s speed is greater than 0.
Hope these help!
Thank you for the reply, i will give this a shot tofay and let you know the result!
Attached is the recommended setup for movement. I did that and then altered the movement inputs, now my W,A,S,D is correctly working. Unfortunately my rotation is still broken. I’m also attaching an example how the rotation breaking. After I move, my character will no longer follow the cursor and rotate. Although it automatically rotates in the direction of travel for some reason. The goal was to have the character moving with W,A,S,D with the forward, backwards left and right movements being relative to the direction where the character is currently pointing (red arrow). Whereas right now when I click “w” for example it breaks my rotation and automatically rotates the character to a specific direction. Thanks again for helping, if you have any further suggestions it would be much appreciated!
Didn’t you enable the Orient Rotation to Movement setting?
That behavior is expected when it’s enabled. I thought that was your second objective.
Actually upon checking the video you provided, it doesn’t even seem like it’s rotating to the direction of the movement. I think there’s something else going on.
Well
Since you said that, I recommended this:
Both won’t work at the same time.
If you want that, you can use the actor’s rotation (or it’s forward vector & right vector) instead. You were using the control rotation earlier. The control rotation is not your character’s rotation.
However, I don’t think you’d want to add such a mechanic to your game, because the camera doesn’t rotate with the character! It wouldn’t be a quite pleasant experience for the player
I agree with you on that being a weird mechanic, I was actually thinking about that. But even so, if I don’t use that mechanic my rotation still breaks and I would like the character to be able to rotate 360 degrees while moving. like you said if I make it so the character cant rotate when the speed is greater than 0 I wont be able to rotate while moving. I did tick orient rotation to movement, however that does not seem to fix the breaking rotation. it also doesn’t stop the character from auto rotating in the direction of travel.
I didn’t say that
I said you should put a Branch node before making the character rotate to the direction of the cursor in order to cut the execution flow there if it’s speed is greater than 0. Because you can’t rotate it to the direction of the movement and also to the direction of the cursor at the same time. But you can enable it back when it’s not moving.
Personally, I’d recommend you to enable the character to orient it’s rotation to the direction of the movement, and disable it to rotate with the cursor when it’s moving to avoid any interference. I think you didn’t do that second thing and that causes the unexpected result.
Oof, sorry for the misunderstanding. although I have a very small background in programing I’m a huge noob still. Anyway, I don’t think that would work good for gameplay if my character is running around shooting things on the move because then how will it acquire targets while moving? I implemented the changes to see what the result would be it still breaks the rotator and gives unexpected results. I appreciate you replying so much, if you don’t have anything else for me its completely understandable .
Jump to the Second Section for Your Objective
Oh right, you should also enable / disable the orient rotation to movement.
Right click on an empty space, search for Orient Rotation to Movement and pick the Set type of it, it’ll automatically be connected to the character movement component. Then enable & disable it after the True & False output exec pins of the Branch node respectively.
Oh wait I think I know what you actually want though, you want the player character to move to the direction of the cursor! I think I get it now! It was clear from the beginning though, sorry about that. Actually I did understand that at some point but couldn’t see how that could be what you want so continued to give you my suggestion I can visualize it better now, no I don’t think it would be a too confusing mechanic, I think I even remember games like that.
Okay so all you need to do is just subtract the character’s location from the world location of the cursor (on the the x & y plane), turn the result into a unit vector by using the Normalize node, and use that to add forward movement input (which will also be backward when it’s negated by the action value), and use the Cross Product node to get the vector that’s perpendicular to our vector by getting it’s cross product with the character’s up vector (which you can get by using the Get Actor Up Vector node) and use that to add right movement vector (which will also be left when it’s negated by the action value)
But even when I do this solution the actual rotation of the character just breaks, as soon as I click WASD at all the rotation just completely stops working. I just don’t understand why I can’t move and rotate at the same time now. I think my biggest issue is figuring out why the rotation mechanic is breaking when the enhanced input is used.
I think it should’ve worked if you followed the steps I explained correctly, but I’ll test it myself when I get to launch my PC again.
Let me know how it works for you! No amount of research has been able to help me solve this issue yet maybe im doing something wrong.
Okay so here’s the Event Tick:
As I noted in the blueprint as well, the subtraction and the base unit vector being the +y direction vector are due to the rotation of the mesh
The movement inputs:
Again, the quirkiness in the action values’s corresponding directions is due to the rotation of the mesh
And here’s the result:
(Sped up to fit)
Hope this helps!
Dude, thank you so much, this literally fixed my problems. Its a shame I don’t really know what is going on though because I feel like I just got spoon fed.
I can answer more personal questions from private messages or Discord if you like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.