Hello
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
{
NodeB.position=NodeA.position;
}
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.
Thanks!
Problem with positioning node with body
-
- Posts: 1
- Joined: Wed Sep 03, 2014 7:45 am
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Problem with positioning node with body
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.
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! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 5 guests