How to make a character stop walking when hitting a wall

Right :sweat_smile: 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! :blush:

1 Like