Lean on a surface FPS

Hey so i was playing frontlines and i wanted to ask for help to know, what logics should I follow to replicate a system like this? in frontlines it detects in which direction is a wall and automatically does the lean then how could I or what logics which detectors should I do to be able to replicate this? I was thinking about raycast but I still can’t decide.


I guess you could try to do a raycast on both sides and see if it hits a wall at a short distance.
Actually, yeah, do that. Probably the easiest, may not be the best, but is also probably the most efficient. Don’t spend too long on one thing in any game anyways.

Like Subtotal said, raycasts are definitely the way to go. You could have the ray’s origin by the muzzle position or the camera, and the ray direction be the character’s look vector. If that intersects you’d have to cast secondary and even tertiary rays towards the left and right at a pretty acute angle, then based on the results of those two rays you can figure out which way to tilt. If the left ray doesn’t intersect by the right ray does, you are probably safe to tilt to the left for example.

Yeah, something like this. I would do 1 raycast coming from the left and right side of the HRP or around that space and then raycast in the direction of the player.

thanks for the help guys i used the comment from @SubtotalAnt8185 and @Bovious to make the scirpt so this is a example of how is going i still need to tweak it but i used camera and raycast to make this

Thanks for the help!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.