- Home /
FPS Controller can jump over anything
Hi, No matter how steep a surface is my FPS Controller(unity 5.0.2) can jump over it.I have mountains who surrounds my map and some of them make almost 90 degrees with the ground.No problem for my olympic champion at jumping/climbing who makes it over them and out off the map.If i understood correctly from unity manual this setting is the "Slope Limit", but there they recommend a 90 degrees value, while the default setting is 45.Either way, except perfectly perpendicular walls, my FPS Controller can jump/climb over anything.How do i correct this behavior?Thanks!
Since you have a terrain you should degrese you slope limit to a value that works best for you. I also have terrain and I have my slope limit to 25. At the unity manual I bet that what they have in $$anonymous$$d is buildings and stuff like that and not terrains.
Thanks cgeopapa,but apparently this is not it.Whatever value i put in slope limit(i tried 25, 10, 5, 0) it doesn't work.By repeatedly pressing "space" i can get in the top of any mountain.$$anonymous$$aybe there is another parameter that i should modify?
Oh, to overcome this issue you can add some colliders to the places that shouldnt be accessible! They dont have to be 100% acurate, just enough so that the player cant get out of the map. An other option is to make a script but I really dont know how you can do this.
I'd like to mention sometimes it works on the character controller to add a physics material to its collider, with 0 friction, and the same on the wall colliders
Answer by FerociousIndustries · May 22, 2019 at 08:57 PM
Hi guys im facing this issue as well. FPS zombie survival, player can escape any room by jumping. Not cool, someone please help
Answer by Cornelis-de-Jager · May 22, 2019 at 09:16 PM
Method 1
Assign a maximum slop against which jumping is valid.
float maxSlope = 45;// Max angle allowed to jump from - Note this angle will be a inverse: 90 - this angle is the actual angle
public bool CheckJumpAngle () {
Ray ray = new Ray(transform.position, -transform.up);
RaycastHit hit;
if (Physics.Raycast(Ray, out hit)){
// Return the angle between transform.up and normal
float angle = 90 - Vector3.Angle(transform.up, hit.normal);
if (angle < maxSlope)
return true;
}
return false;
}
// Example implementation
void Jump () {
if (CheckJumpAngle() && TouchingGround() && ...)
DoJumpPhysics();
}
Method 2
Play around with adding physics materials to your player. Specifically the friction property. This will allow the play to start sliding onces the slope gets to steep and is relatively easy to implement.
Your answer