Rotate to angle
Hi guys,
I'm trying to do a pretty simple thing and I'll appreciate your help.
I have an object, looks like a stick lets say: |
I'm trying to rotate it in a loop to angle 40 and then to 320 and so on in a loop- like swinging.
the object starts with rotation = 40.
What I did is to use the "Rotate to Angle" behaviour. I ask if self.Rotation between 40-45, then rotate to angle 320. if rotation between 320-325 then rotate to angle 40.
What happens is that it really goes to angle 320 for the first time and then goes back to angle 40 as it suppose to but thats it! it doesnt do it in a loop! Only one swing to the left and one to the right. I've tried to play with the "run to completion" "stops on destination" buttoms but no luck...
How do I make it swing in a loop???
Thanks,
Stas.
Comments
You can do it with a couple of constrains . . . . . actually three if you throw one in for rotation.
A = half the length of your stick
B = the number of degrees you want it to swing from 0° (both up and down)
C = speed of the swing
D = horizontal position of the stick
E = vertical position of the stick.
Hold on, I'll do a quick example . . .
Thanks for the detailed answer!
And do you know how would this swinging stick move down lets say?
I mean, moving down while swinging (the Y is changing always)
I posted the various parameters in my post above . . . .
E = vertical position of the stick
@socks do you have the demo file to share???
My Gamesalad Games On App Store:
Greedy Chubby: https://itunes.apple.com/us/app/greedy-chubby/id834371213?ls=1
I don't think I saved the project from the video, but it's simple enough to do yourself, just follow the instructions above, place three constrain behaviours on your actor and adjust the values to suit your needs.
EDIT: demo file . . . . .
https://www.mediafire.com/?azlqyl45jt5fya4
Thanks @socks i did try myself. it turn out not swinging but weird rotating result. Thanks for the file
My Gamesalad Games On App Store:
Greedy Chubby: https://itunes.apple.com/us/app/greedy-chubby/id834371213?ls=1