applyAngularVelocity causes error when called right after object instantiation

Posted by Appeltaart on Game Development See other posts from Game Development or by Appeltaart
Published on 2014-05-14T13:12:51Z Indexed on 2014/06/02 21:50 UTC
Read the original article Hit count: 237

Filed under:
|
|

I'm trying to make a physicsBody rotate as soon as it is instantiated.

CCNode* ball = [CCBReader load:@"Ball"]; [ball.physicsBody applyForce:force]; [ball.physicsBody applyAngularImpulse:arc4random_uniform(360) - 180];

Applying force works fine, the last line however throws an error in cpBody.c line 123: cpAssertHard(body->w == body->w && cpfabs(body->w) != INFINITY, "Body's angular velocity is invalid.");

When I don't apply force and merely rotate the problem persists. If I send applyAngularImpulse at some later point (in this case on a touch) it does work. Is this function not supposed to be called right after instantiation, or is this a bug?

© Game Development or respective owner

Related posts about cocos2d

Related posts about objective-c