Constrain a rotation
MrBloggy
Member Posts: 35
I have an actor which is rotated by the Y accelerometer left and right.
How can i put a constraint on this at 45 degrees each way?
Thanks in advance
How can i put a constraint on this at 45 degrees each way?
Thanks in advance
Comments
If this looks too choppy then I will try a constrain attribute behavior. This is a little trickier as I will need to use vectortoangle and constrain that angle to an attribute in the rotating visible actor. Then I will constrain the rotation of the actor to that self.attribute.
The idea is to use the accelerometer to control the invisible "target" and then have the shooter at the bottom of the screen always rotate to be aiming at the target. Then I will probably put invisible walls to keep the invisible target from going to far. This will control the range of the angle of the shooter.
Sorry if this is a bit confusing - it's too early for me to be completely coherent.
Rule (ANY)
when attribute self.rotation < 45
when attribute self.rotation > 315
Rotate
OTHERWISE
Rotate 0 relative to ACTOR
That way once it hits 45 the otherwise kicks in and it should rotate to 0 relative to actor (if you select relative to scene I think it will snap back to 0)
One of these three approaches should work (probably with some serious tinkering!)