Impact icon indicating copy to clipboard operation
Impact copied to clipboard

Collision FIXED on both entities

Open rontrek opened this issue 6 years ago • 6 comments
trafficstars

Hi, I'm trying to implement a roaming enemy or npc entities which stops the player when collided and vice versa. How do I go about this? If I set FIXED on both player and npc, the npc still slides away when collided.

rontrek avatar Aug 28 '19 03:08 rontrek

If you want the player to get stopped by the NPC, then your player needs to be weaker than the NPC. Perhaps try leaving NPC as FIXED (the strongest), and change the player to ACTIVE (weaker, but still relatively strong). And if you have some entities you want to get pushed by the player, you could assign them LITE (even weaker yet).

Joncom avatar Aug 28 '19 04:08 Joncom

Thanks @Joncom. But I want them to cancel each other out not weaker than the other. If a player bumps the npc, the player stops, same goes with npc when bump into the player.

In short, all entities will be stopped when bumping into each other and they cannot push each other aside. I'm trying to do a top down game.

rontrek avatar Aug 28 '19 04:08 rontrek

Have you tried ACTIVE-ACTIVE or LITE-LITE?

Joncom avatar Aug 28 '19 04:08 Joncom

Yes, the results:

ACTIVE-ACTIVE - still slides either entities LITE-LITE - just passes without any collision

should a FIXED-FIXED type stopped both or is this a bug?

https://impactjs.com/forums/help/fixed-vs-fixed-collision

rontrek avatar Aug 28 '19 04:08 rontrek

..also quoting the specific documentation page, it says:

The behavior for FIXED vs. FIXED collisions is undefined.

https://impactjs.com/documentation/class-reference/entity#collides

Is there a workaround?

rontrek avatar Aug 28 '19 04:08 rontrek