In the game engine, when i have my player walking around the scene it seems to slowly slide down slopes and ramps etc. How can I prevent this sliding from happening just like in most other games?
$\begingroup$
$\endgroup$
3
-
$\begingroup$ Turn up friction on character's physics? $\endgroup$– BlendingJakeCommented Jan 31, 2015 at 3:14
-
$\begingroup$ That didn't seem to do anything. $\endgroup$– christaiCommented Jan 31, 2015 at 3:27
-
$\begingroup$ I've experienced this also without being able to fix it +1 $\endgroup$– ruckusCommented Jan 31, 2015 at 15:59
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
1
connect all the sensors you are using for motion to a python controller.
add a ray sensor, -z that will reach from the origin to below the actors lower collision bound. connect this as well,
sensors --------python
Ray-------------/
break
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
Ray = cont.sensors['Ray']
your_sensor_1 = cont.sensors['YourSensor']
## etc
if not your_sensor.positive and Ray.positive:
own.worldLinearVelocity*=.9
own.applyForce((0,0,(own.mass*9.8)),0)
##if you are on the ground and not pressing any movement keys like forward or backward
## stop moving
-
$\begingroup$ You forget to set the ray sensor to true pulse triggering, but thanks anyway. It worked after that. $\endgroup$– christaiCommented Mar 8, 2015 at 20:54