Problem with positioning node with body

Official forum for the Chipmunk2D Physics Library.

Problem with positioning node with body

Postby dart_nikitos » Wed Sep 03, 2014 7:50 am


I am using cocos2d v3.2 with Chipmunk, here is my problem:

There are two nodes with bodies ( NodeA, NodeB). I am moving NodeA with applyForce function, and i want NodeB to follow NodeA (be at the same place as NodeA). Both bodies are dynamic. My code:

-(void) update:(CCTime)delta
It is OK when NodeA is not moving, but it start moving NodeB follows but positions are not exactly the same. Seems like it setts position with delay.

I've tried also Pivot Joint but result is almost the same.

Please help me if You know where is the problems.

Posts: 1
Joined: Wed Sep 03, 2014 7:45 am

Re: Problem with positioning node with body

Postby slembcke » Wed Sep 03, 2014 9:40 am

CCPhysics (which is not exactly Chipmunk) updates it's physics during the fixedUpdate: method. If you move the positioning call to that it might fix your problem.

What you are doing is a little odd though. Setting the position of a physics body every frame is asking it to "teleport" several times a second. It won't be moving smoothly, and it won't collide nicely with other objects. It sounds like you just want the second node to be a child node of the first instead of giving both of them physics bodies.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! ->
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 3 guests