Hello, I am new to UE5 and I wanted to know if anyone could help me. I have a problem with the character. When he moves towards the wall, he continues walking with the animation. Is there a way to make the player return to the idle animation or stop him from walking?
Get a Line Trace by Channel
node and place it right after the Triggered
pin of your IA. Then get the player character’s location with the Get Actor Location
node and plug it into the Start
pin of the line trace node. Then get the Get Actor Forward Vector
node, multiply it with something like 200 using the multiplication node and add the actor’s location to it using the addition node, then plug the result into the End
pin of the line trace node. Connect the Return Value
of the line trace to the Condition
pin of a Branch
node and trigger your Add Movement Input
nodes after it’s False
pin.
Hope this helps!
(post deleted by author)
Thanks for your reply, it worked but it stopped all movement. Do you know a way so I can make the movement backward, right and left work except forward?
Right I designed that logic in my mind since I wasn’t on my PC so I wasn’t able to test it for myself.
So to fix that, instead of fixing the line trace to where the player character’s body is facing, you can cast it towards the direction of the movement input.
Make a vector with the Make Vector
node, and set it’s x & y components to your x & y action values. Rotate this unit vector to the control rotation by getting the Rotate Vector
node, connecting our vector to it’s yellow pin at the top, then getting the Get Control Rotation
node and connecting it to the purplish-grey pin at the bottom. The rest would be the same, just multiply the result with something like 200, add the actor’s location onto it and connect it to the End
pin of the line trace node.
Hope this helps!
(post deleted by author)
I tried to do the same thing you said but it came out bad. I think I did something wrong. How can I get x and y values? I’m sorry to bother you. I’m new to this.
The control rotation should be dragged out of the player controller
I think you’re already doing it. But you can as well right click on the Action Value
pin of your IA and hit the Split Struct Pin
option on the menu that pops up.
But you did follow the given steps perfectly