Disabling Character's bouncing off of walls?

Hi, semi-new to the BGE here,
I’ve made a simple movement script for my Dynamic character (a cube) and am having an issue when I run into a wall or anything where the character gets pushed around. I don’t want to set the physics type to Character because you can’t jump with that. Anyone have a solution? It would be much appreciated. Here’s what I have at the moment:

import GameLogic


cont = GameLogic.getCurrentController()
player = cont.owner


default_speed = 0.15
jump_force = 8000
x = 0
y = 0


if cont.sensors["Forward"].positive:
    y = default_speed
if cont.sensors["Backward"].positive:
    y = -default_speed
if cont.sensors["Left"].positive:
    x = -default_speed
if cont.sensors["Right"].positive:
    x = default_speed
if cont.sensors["Jump"].positive and cont.sensors["OnGround"].positive:
    player.applyForce([0.0,0.0,jump_force],False)
if cont.sensors["Sprint"].positive and cont.sensors["OnGround"].positive:
    y *= 1.5
player.applyMovement([x,y,0.0],True)

you could use character movement along with the character motion logic brick, but its not using python :confused: if thats a problem.

Take a look at solarlunes player movement script. He fixed this problem with a method I cant recall offhand.

In all honesty I’m not sure I understand the problem, but I’ll try and help anyway :). The way I would handle making the player stop moving when colliding with a wall is with a ray sensor. I’d make a ray sensor that points in front of the object and has a distance of how large the player is. Then in the python script you can check if the ray sensor activates(or the player is right next to a wall) and then change the players velocity. You would probably have to do the same for the left and right sides as well :).

Another way might be to simply turn up the physics substeps(world panel), as that will have better physics precision and might fix the bouncing :).

I would firstly recommend trying to use linear velocity instead of the applyMovement function, as that’s basically just translating / teleporting the game object, which could be the case of that “bouncing” issue. Also, there’s no need to go with GameLogic at this stage - you can just use bge.logic.

applyMovement is in that way an incorrect name as it sets the position rather than to apply a motion. In terms of Physics you can see it as teleporting.

Which is probably the reason that your character “bounces” off walls. What might be happening is that you are teleporting your character slightly inside the wall and then the physics engine pushes them apart and flings your dynamic object back a little bit.

Thanks a lot for the responses, I’ll check them all out.
In lieu of creating a new thread, does anyone know why there’d be a hole in my skybox right in front of the camera?


Looks like you need to set your cameras clip end to a larger value

Look there are 2 things you can’t have enough of in video games 1: Ridiculously shiny surfaces and 2. unnecessary bounciness. And you call yourself a game designer. Heresy! Arrest this heretic! =)