I've got a strange problem and I'm not sure what the cause is, or how to debug it. In my game I throw a physics object as far as possible. All objects are placed in a content node that I move every frame to ensure that the object doesn't leave the screen. The problem is that the object is behaving weird and choppy.
Here is a video clip of the problem occuring: [video]https://www.dropbox.com/s/a0ex925xkxujflb/problem.mov[/video]
(you see the object suddenly moving forwards and backwards. For example at the 6.5 second mark).
The code I use to follow the object gets called in the update method and is as follows:
CGPoint fullScreenSize = CGPointMake(self.contentSizeInPoints.width, self.contentSizeInPoints.height);
CGPoint halfScreenSize = ccpMult(fullScreenSize, .5f);
// camera dampening factor
float damping = 0.8f;
// save old camera position to dampen the camera movement later
CGPoint oldPos = _contentNode.position;
// calculate new camera pos taking world boundaries into account
float newCameraPosX = clampf(halfScreenSize.x-_toilet.position.x,-100000000,0);
float newCameraPosY = clampf(halfScreenSize.y-_toilet.position.y,-100000000,0);
CGPoint newPosRaw = ccp(newCameraPosX,newCameraPosY);
// damping the camera movement and setting it
_contentNode.position = ccpAdd(newPosRaw,ccpMult(ccpSub(oldPos, newPosRaw), damping));
Does anyone see what I'm dong wrong, or have an idea where the problem might lie?