This is a 1st person game. I need my character to stop moving towards the wall, as soon as he makes contact with it, even if the “Move forward” key is being pressed. Though I also need him to be able to move forward if he’s not fully facing the wall, even if he’s in contact with the wall. I wanted to know how I could make it so that, he will be able move forward, depending on the camera angle at which he’s facing the wall. I believe I need to set some kind of angle threshold for it to work.
Hi @kHynnS
Maybe a simple trace , set the distance to just in front of the player and if it hits the wall objects then set a boolean that you can check in the movement code. If true dont allow walking if false allow. Make sure you set the boolean to false if the trace hit is false.
You may have to tweak to distance a little as you test so suggest you turn on the trace visibility a few secpnds or maybe permanent until you happy
Yeah, I think that would work when walking forward, but what if I walked backwards, sideways or diagonally? It would be weird if my character kept moving towards the wall in any of these directions. How could I make the trace follow the direction I’m walking?
Hey @kHynnS!
So you can get the character’s velocity and use that with a multiply node to get your end point for your trace!
For the sake of Occam’s Razor, what is preventing you using blocking volumes?
I think the issue is they want their character to be unable to move towards a wall they’re adjacent to, they’re being stopped but they’re rubbing against it- they want their character to not animate or attempt movement in that direction in any way.
Im not sure how your inputs are setup but I used this from Third Person on an FPS character. It functions but the concept is problematic because once you hit a wall your velocity then becomes along the wall and the trace doesnt hit the wall after that initial contact.
You could trace in 4 directions when moving this way you get the cross directions and atleast one trace should be hitting a wall when youre near it.
I’m actually using the TPC as 1st person. I don’t know if you tested it or not but I think the trace in 4 directions might not work because of the gaps between the lines. The way i’m trying right now is working walking forward, so I only need to make it happen walking backwards and sideways, but don’t know how.
I did some quick testing with the four traces method and it seemed fine. It allows you to know which direction the obstruction is and you can check that against the input direction. The main issue Ive found is in the diagonals and skating along the wall that way not so much the main directions, moving to a box trace could give more overlap and make the gaps between the directions smaller.
As I mentioned previously the issue with using velocity in regards to the trace is that collisions change the velocity direction. It stops movement directly towards the wall you still end up with the issue when being able to skate along walls
Edit: maybe trace using the input direction rather than velocity but if youre limiting input its a similar issue since youre zeroing them out, if youre modifying velocity then you’ll still have the data.
Yeah, It worked using input direction, but instead of a Multi Box I used Multi Sphere and set the Multiply to 10, increasing the size of the sphere in the direction of the input.
Sorry i did read your title and you said facing wall so i presumed facing as lookong forward
No problem, I should’ve been more specific.