What is the best strategy for animating physics bodies?
- applyForce(), applyImpulse() etc.
- Depends on the situation
I’m working on a game using physics bodies. At the moment I’m animating bodies using SKAction. This works fine. In my case I need objects that move from one side of the screen to the other.
You must consider what kind of movement you need. Remember that forces are continuous (iow they accumulate over time) whereas impulses dont. Otherwise youll start seeing how your objects suddenly disappear from view.
Thanks for the reply. I guess I was really wondering whether using an Action to set the position of a physics object created problems for the physics simulation. In which case it might be better to use an impulse or force.
In practice using actions or setting the position in update seems to work fine.
There are definitely situations where actions make things much easier to accomplish, and other situations where impulse or force create the better effect and make more sense.
My understanding is that using an action will often be ok for moving the physics body but it can cause problems with the collision detection. That is the issue I had with the game I am working on. I swapped the action for impulse and collision worked properly.
That brings up a good point. Actions are probably good with physics when you are using physics for contact detection. Actions are probably not good when you are using collisions.