Strange Lerp Behaviour

Strange Lerp Behaviour
0.0 0


Hi Guys,

I’m using linear interpolation to rotate a sprite to point at the mouse pointer, using the cc.lerp() function. I’m getting some strange behaviour, which I think may be something to do with chipmunk. The object being rotated is a ccPhysicsSprite, and I’m finding that if it knocks into another object, it goes “out of sync” with the lerp function. For example, my debug output shows that the orientation of the sprite is 90 degrees, and the target orientation (that it is lerping towards) is 120. For some reason the lerp function seems happy just to leave the two values, and for some reason stops interpolating properly. Like I said, it only happens sometimes after the object knocks into something else, so I’m guessing it’s something to do with chipmunk.

Any help is gratefully received :slight_smile: