# Collision Jittery; UPBGE

I have problems with collision in my game. When the player character runs into a wall or a steep slope, the character jitters violently. I have not seen any way to possibly fix this. Is this just normal collision for BGE/UPBGE? I’ll link the .blend file to see if anyone can help. (The game uses joystick controls).

My old PS2 controller doesn’t want to work on this so I can’t test it.

Anyhoo, probably not your ideal solution, but in case you wonder: way I deal with wonky physics is have my own code clip the movement vector. This is quite problematic and requires subclassing gametypes, plus I haven’t really gotten around to optimizing much. Then why do it? Because I like statics, triangle meshes and predictable behaviour.

Simplest example I can think of;

``````from bge.types import KX_GameObject

class Obj(KX_GameObject):

def __init__(self, old_owner, pos, **kwargs):
for key, value in kwargs.items():
self.__dict__[key] = value

def applyMovement(self, vec, local=False, prop=""):
self.clipMove(vec, prop)
KX_GameObject.applyMovement(self, vec, local)

def clipMove(self, vec, prop=""):
vol = self.cullingBox.max

xdirn = -1 if vec[0] < 0 else 1 if vec[0] > 0 else 0
ydirn = -1 if vec[1] < 0 else 1 if vec[1] > 0 else 0
zdirn = -0.25 if vec[2] <= 0 else 1
f = 1.5

#do this for every axis.
if vec[0]:
for y_offset in [ vol[1], -vol[1], 0 ]:
lpos = self.worldPosition + (self.worldOrientation.col[0]*(vol[0]*f*xdirn))
lpos = lpos + (self.worldOrientation.col[1]*(vol[1]*f*y_offset))

xclip_ray = self.rayCast( objto=[ lpos[0], lpos[1],
self.worldPosition.z+vol[2]/2 ], objfrom=[ self.worldPosition.x,
self.worldPosition.y,self.worldPosition.z+vol[2]/1.25 ], prop=prop)

if xclip_ray[0]:
vec[0] = 0
break``````

NINJA EDIT: forgot them imports.

Definitely gonna try this next time it happens. I actually found out what was going on. The platforms I were using were wider at the top than the bottom. I used a Triangle mesh for the collision bounds, so the gap was still present. The character’s collision bounds were a bit taller than the gap left in the platform, so it was freaking out trying to squeeze through. Using a box collision shape now and the collision is much more stable.

Thanks for the help with code, though!