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$
  • $\begingroup$ Turn up friction on character's physics? $\endgroup$ – BlendingJake Jan 31 '15 at 3:14
  • $\begingroup$ That didn't seem to do anything. $\endgroup$ – christai Jan 31 '15 at 3:27
  • $\begingroup$ I've experienced this also without being able to fix it +1 $\endgroup$ – Scalia Jan 31 '15 at 15:59
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$
  • $\begingroup$ You forget to set the ray sensor to true pulse triggering, but thanks anyway. It worked after that. $\endgroup$ – christai Mar 8 '15 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.