Rotating from a specific angle in a pendulum like manner (using only one actor)
ADSentertainment
Member Posts: 397
So for a game, I'm trying to make a swinging axe for something, and I'm trying to make to make it pivot from a single point. I know how to have something rotate from another point and around another actor, but is it possible to do this with only one actor and have it move like a pendulum? This is what I'm trying to achieve (only a little smoother :P):
Having trouble with your game? Sounds like a personal problem.
Comments
Yeah, that's pretty straightforward, you just need to rotate the actor around a point using sine and cosine, but make the angle they both operate on a sine wave, hope that makes sense.
Example, if your actor is 160 pixels tall . . . .
Hold on, this is getting messy, let me make a demo project . . . . . back in a minute. . .
Demo.
Link: https://www.mediafire.com/?271as5qtbzan797
I actually was able to figure it out fine, but thanks! It helped a TON. Quick question though, does the 80 in the expression state the pivot location? Because I changed it from 80 to 96 since it wasn't pivoting around the the end of the rod and then it pivoted around it fine.
Having trouble with your game? Sounds like a personal problem.
@ADSentertainment -- I like @Socks way of making a pendulum animation. (And I prefer to do it that way.) But just for kicks, here is another real fun way of making an actor swing like a pendulum.
80 was simply half the height (the radius) of my example size ("Example, if your actor is 160 pixels tall. . . "). So you could say the 80 states the pivot point.
So, if 96 worked for your particular actor, I guess your actor was 192 pixels tall ?
I can't look at the attachment as I'm not at my real computer right now, but I am going to guess that coming from you it involves some fiendishly clever maths !
Thanks! It does use radians (converted to degrees) but hopefully everything is straightforward enough to be useable. Its mathematically equivalent to your suggestion. It just uses the move behavior to reposition the actor's x,y coordinates -- rather than using two constrain x,y behaviors.
Precisely. That's what I meant to say
Having trouble with your game? Sounds like a personal problem.
Just taken a look . . . . scary stuff ! : ) Really neat, but scary nonetheless.
@RThurman and @Socks
I bow to you gentlemen. Fantastic stuff as usual.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
@Socks and @Braydon_SFX -- I swear its GameSalad! Its just a fantastic tool to work with!
@RThurman nice file man
what to do in order to change speed, swing range, and starting angle?
for example:
make the axe swing in a smaller arch, closer to the floor
Hi guys,
How do you make it to swing starting from the left to the middle and then vice versa?
Thanks
only swinging halfway than the script you guys gave.
Constrain X to 98 *cos((45 *sin( self.Time *160))-135)+512
Constrain Y to 98 *sin((45 *sin( self.Time *160))-135)+384
Constrain Rotation to 45 *sin( self.Time *160)-45