3
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ Turn up friction on character's physics? $\endgroup$ Jan 31, 2015 at 3:14
  • $\begingroup$ That didn't seem to do anything. $\endgroup$
    – christai
    Jan 31, 2015 at 3:27
  • $\begingroup$ I've experienced this also without being able to fix it +1 $\endgroup$
    – ruckus
    Jan 31, 2015 at 15:59

1 Answer 1

0
$\begingroup$

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
$\endgroup$
1
  • $\begingroup$ You forget to set the ray sensor to true pulse triggering, but thanks anyway. It worked after that. $\endgroup$
    – christai
    Mar 8, 2015 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .