[SOLVED] Collision Component not working

Good day! I am trying to create a 2D game for personal use. However, I am having a hard time figuring out why the collision component is not working. My character is still able to walk through walls even if I already added a rigid body and collision component. What do you guys think is causing this? I’ve been doing similar projects before, but this is my first time encountering such a problem. Is this a bug?

Hi @cormilyn_g,

How are you moving your character? Are you using physics or just something like setLocalPosition()/translateLocal() ? If you are moving the character without physics, and they have a dynamic rigidobdy type, the collider is not actually being moved, so the engine never thinks it’s colliding with anything. You will have to use forces or impulses to ensure that the physics simulation and collision is accurate.

If this is the case you’ll probably be able to see this behavior at runtime with @yaustar 's excellent devTools here:

var Walk = pc.createScript(‘walk’);

var mcDir = 270;

Walk.prototype.update = function(dt) {

// pos = this.entity.getPosition()




    mcDir = 180;

} else if(this.app.keyboard.isPressed(pc.KEY_LEFT)){



    mcDir = 0;

} else if(this.app.keyboard.isPressed(pc.KEY_UP)){



    mcDir = 90;

} else if(this.app.keyboard.isPressed(pc.KEY_DOWN)){



    mcDir = 270;


    if(mcDir === 0){


    }else if(mcDir == 90){


    }else if(mcDir == 180){


    }else if(mcDir == 270){





-This is how my code looks like.


My character’s rigid body is already set to dynamic but it’s still not working.

I took a look at your project, and I see that you have the sprites on a 2D screen. This is generally incompatible with the sprite system, and if you use the devTools at runtime, you can see that your physics shapes are very small, and likely not in the correct position. Try saving a checkpoint and then removing all of the sprites and colliders from the 2D screen. You’ll have to do a fair bit of rearranging, but it should help with the warping of all the physics objects

1 Like

It worked! Thanks so much.

1 Like