[SOLVED] Collision in 2D

Hi! this may sound like a lame question but how do i prevent my animated sprite from going out of the map… like I want it to “bump” it from something so that it can only be on the map.

Hi @iscm and welcome!

You can create wall entities around the map with a collision component and a static rigidbody component. Make sure you give the collision component the correct size.

The animated sprite should have a collision component and a dynamic rigidbody component. Make sure you move the sprite with forces. Probably you need to adjust the values of the rigidbody component to get the desired movement.

For more information you can check the pages below.

https://developer.playcanvas.com/en/tutorials/collision-and-triggers/

https://developer.playcanvas.com/en/tutorials/Using-forces-on-rigid-bodies/

1 Like

Can’t a kinematic animated sprite work against a static rigidbody component?

Unfortunately, a kinematic rigidbody is not stopped by another rigidbody.

Oh I see, well thank you for helping me! I appreciate it

1 Like