Michael Austin Michael Austin - 1 year ago 42
iOS Question

Can I have physics bodies collide without pushing each other?

I have a game made of little SKNodes moving around. They can not overlap, so I use physics bodies, so that they move around each other. However, in the case that one sknode is animated to follow another, it pushes the sknode ahead. Setting the collision bitmask to 0 makes them overlap, so that is not an option. But otherwise, they push each other way beyond my desired speed. I need a way to get rid of the 'pushing' without overlapping using skphysics bodies. Is there a property I can set to fix this?

Notes: I use skanimations to move my nodes around. If you need any pertinent code, tell me... I don't know where to start. I am using Swift 3.0, but I will accept answers with 2.2/2.3 syntax.

EDIT: The real solution was to change the node's velocity instead of animating movement

Answer Source

Change the restitution on your physics body of the moving object to 0 when a contact happens, and set the weight of the object you do not want to move really high

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download