Search code examples
objective-csprite-kitgame-physics

Static AND moving?


I want a node to be static. So, that it is not affected by gravity and or collision. But, I also want it to move, is that possible? If I set name.physicsbody.dynamic to no it is not possible to apply a force or an impulse. I also tried to do it by an action - also failed - any ideas?


Solution

  • You can move a static physics body by setting the node's position manually or moving it with a move action should also work. But collision behavior may not be what you expect.

    The alternative is to create a dynamic body with affectedByGravity set to NO and a collisionBitMask set to 0. You can move it with forces but it won't collide with anything (unless you add that category to the collisionBitMask).