0
\$\begingroup\$

I'm trying to implement a collision on ImpactJS entities that both will be stopped when collided and being pushed.

This will be exactly similar to player to player collision on top down games such as Battle City where you can't push the other player and vice versa.

All collision type combination does not seem to work on this case. It still pushes the other and FIXED vs FIXED is being ignored.

\$\endgroup\$
  • \$\begingroup\$ Usually this type of effect is done by using kinematic bodies and shape casts to search for the last non-intersecting position, then place the body there. That way you're not relying on collision resolution to fix an overlap by pushing the bodies apart. I'm not sure how that would be written in impactjs though. \$\endgroup\$ – DMGregory Aug 28 at 11:21
  • \$\begingroup\$ Thanks @DMGregory. I actually found a solution, though not exactly what I need (still pushes player 1 pixel) it works for now. Player = PASSIVE, Entities = FIXED with managed movement. \$\endgroup\$ – ruzip Aug 31 at 0:49
  • \$\begingroup\$ Great! Post it as an Answer below. :) \$\endgroup\$ – DMGregory Aug 31 at 1:01
  • \$\begingroup\$ I will probably leave it as a comment above since it does not completely solve the problem. I'm still looking for the FIXED vs FIXED solution. \$\endgroup\$ – ruzip Aug 31 at 3:22
  • \$\begingroup\$ You probably won't find a fixed vs fixed solution. The documentation says "The behavior for FIXED vs. FIXED collisions is undefined." — So, better to post your answer now as "the best option found so far." Someone (including yourself) can always come along later and add a better answer, even if there's already a working answer there. \$\endgroup\$ – DMGregory Aug 31 at 3:28
0
\$\begingroup\$

This solution is only a workaround and not what I'm exactly looking for but close. It still pushes the player 1 pixel back if the entity collides with player.

Player = PASSIVE, Entities = FIXED

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.