1
\$\begingroup\$

I have seen on many games the ability to push entities around and bump into enemies/characters. What is this called?

I have implemented Matterjs to accomplish this with Pixijs but it seems overkill when I just need the ability to bump and push. I'm not really interested in an accurate physics model, just collision enough to allow the character to interact with the environment.

I can't seem to find out what this is called. My idea is to have all entities defined by a circle collision boundary, and move away from the character based on primitive collision detection and a tangent force calculation to displace.

\$\endgroup\$
  • \$\begingroup\$ That's still a physics system, just a simple one mainly focused on collision-detection and collision-resolution with circle/disc collision primitives \$\endgroup\$ – DMGregory Oct 27 '18 at 8:35
  • \$\begingroup\$ Thank you, collision-resolution should help me begin researching how to do this. After reading other questions, I think a more concise way to explain this is that I'm trying to prevent circles from penetrating whithout halting motion. So they bump and push other ones until they reach their destination. Is there a way to do this by modification of physics properties in an actual physics engine? \$\endgroup\$ – HomestuckBrother Oct 27 '18 at 12:37
  • \$\begingroup\$ You can disable rotation and add collision handlers to fine-tune the velocities assigned to circles after they exit collision. Note that not every collision is resolvable without diminishing velocity though (imagine a line of balls pushing against each other, with the lead ball pressed into a corner). Would you like to edit your question to describe what you're trying to do in your physics engine of choice, and where you need help making the correspondence modifications? \$\endgroup\$ – DMGregory Oct 27 '18 at 13:24
  • \$\begingroup\$ My solution to this is ended up being setting air friction very high and gravity to 0 (this gives the illusion of top-down point of view). This simulated exactly what I was looking for, entities that can bump into each other and push each other around without it feeling like the player is on ice. I did end up using MatterJS but this is a general purpose solution that I'm sure can be used for any 2D physics engine. \$\endgroup\$ – HomestuckBrother Oct 29 '18 at 11:00
  • \$\begingroup\$ Sounds like it's worth sharing as an answer. :) \$\endgroup\$ – DMGregory Oct 29 '18 at 11:16
0
\$\begingroup\$

I ended up finding a solution to my somewhat nebulous question and it ended up being quite simple: I set the air friction to an arbitrarily high value (to dampen movement) and the gravity to 0 (to simulate a top-down perspective). The entities can now bump each other around properly. This was easily and accurately done with the MatterJS library by setting the airFriction and gravity.y properties.

| improve this answer | |
\$\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.