Slope Limit overridden with Space Bar, anyway to avoid?

I noticed that Slope Limit is overridden if you press the space bar while you are climbing. This is a real issue when you are trying to limit what areas the players can access. Is there any way to avoid this? Not sure if it’s exactly a bug it’s more a cheat I’d like to eliminate.

I love the fact it’s so easy to set things like Slope Limit since it’s usually a script function. I’m a huge fan of Unity being an artist first and not a programmer. It’s the only artist friendly engine I’ve ever seen. Even the scripting is pretty straight forward.

Thanks. I’m hoping there’s an easy fix for this one. It would be something I’d consider disabling.

There is no built-in functionality that would change Slope Limit when pressing the space bar. If it changes, that means somewhere some script changes it. So it’s only changing whatever script you’re using.

Hrm, yeah, and boosting the gravity on the FPSWalker script doesn’t help.

2 solutions: Put invisible colliders (you can just use planes, and deselect the Mesh Render component) to block access to those areas, or use one of the other physics-based Character Controllers on the wiki.

Use box colliders instead, they’re more efficient.

belseth, when you hit the space bar you’re jumping. so you aren’t touching the ground. slope limit and step height aren’t overridden they just have no effect when you’re in the “air.” as said, use colliders.

Sorry no one replied for days so I hadn’t checked the post in a while. Thanks everyone. I did get the fact it was jumping it just negates slope limit when it’s jumping. Games like WoW seem to avoid this problem so there has to be a solution in the coding.

I guess colliders are a solution but it means ringing the entire perimeter of a game level to avoid people wandering off the game. Say you set up a mountain range as a barrier then it means running barriers around the whole mountain range near the top. Just wish there was a better solution.

Perhaps its a case of removing the jumping feature in the code? should be easy enough to do if you dont need that functionality
AC

Does the character controller ever ‘land’ while it’s climbing up a slope? If so, you might be able to add some code that disables jumping based on the normal of the surface you’re walking on.

Either that, or have the character controller slide down if the slope is too steep; seems to me that’s what most games do.

–Eric

A combination of what Eric5h5 and Marble suggested seems to be the way other games handle this. I’m one of those people who enjoys trying to get where they’re not supposed to, so I know exactly what you’re fighting with. When you get to a steep area, sliding downward starts to occur and you’re usually not able to jump upward, only back and out.

Defmech had an interesting thought there. I’m an artist and not a coder but it seems you should be able to define the angle of a jump based on the incline. This would effectively make you jump backward instead of forward. It would have to be based on the incline itself so say on a 5% incline you’d still be able to jump forward but say on a 45% incline you’d jump backward. If it can be scripted that would seem the best. That or the slide solution sounds good, either would work.

I agree about liking cheats to get places you aren’t supposed to get but it’s a little too easy a cheat. I actually found it by accident so it’s a little too obvious.

Thanks again for all the thoughts. I love the new terrain editor and all the user friendly functions. I’ve been able to add some game play with zero scripting. Pretty staggering.

Belseth,

There is a terrain call to get the normal. You can then use this to stop the jumping when the angle of the normal is beyond a certain value.

function GetInterpolatedNormal (x : float, y : float) : Vector

I also need this sort of functionality so will post the code.

Richard.

I have an idea, but I’m in the process of learning Unity at the moment, so I’m not sure of all the functions it has, but here’s my idea to this problem (im thinking about it because I have to implement it eventually, lol):

Ok so what if you do a raycast from the player’s position and you get the normal of the face of the terrain the player is standing above as a vector (x,y,z).
So you have the players up vector (0,1,0), and the normal vector, and find the angle between them.

If the angle is greater then a certain amount, (0 should be standing on flat ground, and 90 would be standing next to a wall) then start the “sliding” mode.

If you could “modify” the direction the normal is pointing in, (or just ignore the Y value), and only take into account the X and Z values, then you essentially have a “push” direction that you can start pushing the character in, which should be away from the steep part of the terrain. Since its in fall mode and you cant jump, you could let it push the player away from the cliff and gravity will pull him down.

All the while keep doing a raycast from the player to the terrain below, and when you find a face that isn’t too steep, resume walk mode again.

It all works out perfectly great in my head, now I just need to find a way to implement it. LoL. Hope this helps in some way, and if I can ever get a working example I will post it up here.

sorry to dig up this old tread but i’m having a similar issue and it really needs to be fixed as slopes play an important part in the game i’m coding.

this i believe is the best solution has anybody come up with any code examples that fix this?

There is a brand spanking new fps-controller that deals with these issues in the coming Unity 3.0, so please stay tuned :slight_smile:

well i’m using my own player controll script that uses the character controller and i was just wondering if there is any way of detecting the slope of the normals of collision down.
i cannot afford unity 3.0 so not any help to me.
and this is for a project with an ever closing release date

thanks for the heads up though.

Hey brokenpoly, could you elaborate a bit more on this? You have my undivided attention, as this is a major area I need improvement on.

My biggest gripe that I have with the FPS Controller is it doesn’t handle sliding automatically down a slope (hard to implement, at least for me), and it doesn’t stick to the terrain when going down a hill (ie - bounces down the slope)

I have come up with solutions to these problems, but none of them work 100% as expected, so I am really hoping these get addressed in Unity 3.0

http://www.unifycommunity.com/wiki/index.php?title=FPSWalkerEnhanced

–Eric

Hey Eric. I had originally gave that script a try, but still ran into issues where if the controller is on top of a box and you run off the edge, occasionally it would dart off at an increased velocity.

Actually its been a while since I tried that script, and it could have been my implementation, so maybe I will give it another go.

cheers eric thats perfect now to pull it appart for my own functionality and include it in my own script :twisted: