Can someone please show me how I would limit the zRotation "it's rotatable range" of an SKPhysicsJointPin physicsbody object from its starting point.
I currently have an issue when I use shouldEnableLimits that forces my physicbody object to move unexpectedly/glitch when its rotation is rotating from +270degrees into -90degrees (from positive to negative etc) so I need to use another way to achieve this limiting rotation that lowerAngleLimit and upperAngleLimit provided.
I have a physicbody that is continually moving all over the screen and I use:
myobject.physicsBody applyTorque:lateralMove" //(+ and -)
to rotate this body left and right. As the body is moving I just need the body to be only able rotate in a set amount / "range" as it moves around the screen.
I'm not sure how I go "hey object your center point is here, you can't zRotate past -0.7 (left) or 0.7 (right) from your center etc".
Been racking my brain for over a week on how I can do this, any help would be great
///////////// Heres whats happening if I do a test case
if (_myobjectdegrees > 265) {
NSLog(@"please don't glitch!");
myobject.zRotation = -1.5f;
}
//heres my consoles output
current zrotation 2.949927
current zrotation 3.002563
current zrotation 3.033562
current zrotation 3.061646
please don't glitch!
current zrotation -1.500000
current zrotation 0.212812
current zrotation 1.947406
current zrotation -0.485760
current zrotation -2.326967
current zrotation -2.381383
// it glitched, the numbers after I set -1.5 should start be going back to -1.49, -1.48 back to 0.
//myobjectdegrees is an integer converted to degrees from radians based of my myobject.zRotation
I find I do
//if (myobject.zRotation > 4.6) {
This case is hardly ever triggered. The object is constantly moving/rotating.