accurate collisions

i’m creating a side scroller, and my collision setup is behaving a little off… at least in my computer, as soon as i hit P and try to walk right, the player collider gets stuck at the edge and doesn’t go forward. once i go back and try it again, it runs normally. quite weird.

i wouldn’t want to have to change the collision bounds type or give it a margin, since i want to have accurate collisions for my objects. does anyone know how to help me with this? it really annoys me…

i’ve searched the forums around and came across issues related to what i’m asking, but not EXACTLY what i’m looking for, so any help would be much appreciated.

game.blend (464 KB)

Mine, is a giant pain in the *** but I use physics and rigid body dynamics to animate :smiley:

  1. I do not see any problem. When I try you demo file everything works as expected. I do not get stuck. Could you try to show with a screenshot and more precise instructions exactly how to reproduce the problem?

  2. To get a good basic understanding of bullet physics, I would look at this thread: http://www.blenderartists.org/forum/showthread.php?283412-Studio-Physics-Demo-Constraint-Strings-(-Mouse-Grab)

hummmm… interesting… unfortunatelly, my computer suffered i minor hardware hickup, and my original blend file went with to maintenance, but i find it very odd how everything works fine on someone else’s computer, and glitchy in mine… why might that be?

Trying to do collision boxes for my zombies, sometimes they don`t register :confused:

I know you said you didn’t want to give it a margin but I couldn’t get any collisions to work right at all until I gave my objects a small margin, like .01. Of course, I haven’t looked at your blend so maybe you have a small margin. I have found that if the margin throws off the accuracy of the collisions, shrink your collision mesh a little bit so that it is inside of the non-collision mesh. Through trial and error you should be able to have a margin and collisions appear right on the non-collision mesh.

hum, i guess i could do that ^^, sounds appropriate… it does suck a substancial amount of buttocks when we see dodgy behaviors on collisions when ticking with these things… sigh

Change the player’s Collision Bounds to Convex Hull and give it a Margin of 0.05. That seems to solve the issue. Also disable Damping if you won’t need it.

Edit: A little off-topic, but I think logic computation is to high for what it’s doing.
Edit2: I see now, use_debug was enabled on the Controller. Don’t forget to disable this after you finish the script. However, the script could be better/faster. Here’s just an example of how it could be. Notice that the variables are on top. You only have to get them once. Also you don’t have to import the bge if you only need logic and events. Also you set the linearVelocity twice for both the left and the right movement. Better to first get the motion value and then just set linearVelocity once. Just to give you some pointers.

from bge import logic, events

runSpeed = 10
walkSpeed = 6

def movement(cont):
    player = cont.owner
    keyboard = logic.keyboard.events
    active = logic.KX_INPUT_ACTIVE
    just_activated = logic.KX_INPUT_JUST_ACTIVATED
    left_arrow = keyboard[events.LEFTARROWKEY] is active
    right_arrow = keyboard[events.RIGHTARROWKEY] is active
    up_arrow = keyboard[events.UPARROWKEY] is just_activated
    dKey = keyboard[events.DKEY] is active
    direction = right_arrow - left_arrow
    speed = runSpeed + (walkSpeed - runSpeed) * dKey
    player.linearVelocity.xy = direction * speed, 0