What would be the best way to achieve rotating an object as if it's swinging like a pendulum to the left and right, almost like an object hanging from a balloon?
Good ol' parabola and algebra 2. Too bad I don't remember much from it, and it hasn't even been a year yet. Ok, equation: (y - k)^2 = -4a(x - h). The negative is to flip it over, otherwise, it'd be an arc instead of the path of a pendulum. H and K are the x and y coordinates respectively. You don't have to enter anything for the actual X and Y in the equation. The "a" will determine the width of parabola, fractions make it thinner, whole numbers wider. I might be wrong about a couple things. Second set of eyes to look over this would be great. Mind you, once you have the parabola down, you're gonna have to find a way for it to swing one direction, stop, then the next. I'm thinking a timer function? ... yeah, so, fun, right? Right?
I would think you could just interpolate the rotation attribute around its center point between a high and low value...such as 220 to 320. But the actor would need to be twice as big...to allow the pivot point of the graphic to be the center point...not an end point. Just make the extra actor space transparent above the pivot/center point.
I've never actually done this...but it seems like it would work in theory.
_______________________
*** visit www.spiritApps.com to check out the Spirit Connoisseur Apps *** (Rum and Vodka now available for 17+) _______________________
For landscape where it is swinging through the center
Constrain Attribute: self.Position.X To: 160*cos(self.Time*200%360)+240 Constrain Attribute: self.Position.Y To: 40*cos((self.Time*400%360)+160 Constrain Attribute: self.Rotation To: vectorToAngle(240-self.Position.X,160-self.Position.Y)+90
160*cos determines the swing amount back and forth 40*cos determines the up and down amount
200 and 400 are the speed (I had to play around with these to make it work - for a little fund make them different amounts and see what happens) +240 and +160 makes the center point of the screen (want it lower, make the +160 just +60 or something)
The +90 on the rotate is an offset for me to make my object be rotated how I wanted it.
A3MG said: For landscape where it is swinging through the center
Constrain Attribute: self.Position.X To: 160*cos(self.Time*200%360)+240 Constrain Attribute: self.Position.Y To: 40*cos((self.Time*400%360)+160 Constrain Attribute: self.Rotation To: vectorToAngle(240-self.Position.X,160-self.Position.Y)+90
160*cos determines the swing amount back and forth 40*cos determines the up and down amount
200 and 400 are the speed (I had to play around with these to make it work - for a little fund make them different amounts and see what happens) +240 and +160 makes the center point of the screen (want it lower, make the +160 just +60 or something)
The +90 on the rotate is an offset for me to make my object be rotated how I wanted it.
<dense mode> So what am I missing? Where is the motion coming in? I've tried using this exactly and nothing is happening. </dense mode>
@design219 - Yes, it's possible to make the pendulum slow down and stop. The '200' and '400' in A3MG's original equations represent the speeds. If you replace it with an attribute that decreases over time, I think this effect can be achieved. I'll try it out before I e-mail you the project -- probably in six to eight hours from now.
Edit: Oh, and we would have to decrease the '160' and '40' amounts (the length of the arc) as well.
@design219 - I just sent you an e-mail with two files attached: the original one, and one where the arm of the pendulum has been added and the pendulum slows down.
I couldn't get the newer version to work smoothly, I'm afraid. I'm sure that there's a better way to achieve the effect you want; however, at this point, I don't know what it is.
This was awesome, very helpful. I know I'm revealing just how awful at math I really am, but how would I apply this to make an actor move around in a circle? I'm trying to get an actor to move in a circle around another object but it is eluding me as to how. This looks promising but after monkeying with it for quite a while I cant make it work how I want it to.
Look at the behaviours in his Orbital actor where he constrains the x-coordinate of Orbital to:
60*cos( self.Time *300%360)+ game.TankXPosition
and its y-coordinate to:
60*sin( self.Time *300%360)+ game.TankYPosition
In these equations:
60 represents the radius of the circle (in pixels).
self.Time *300%360 is the angle. Here, it increments itself (because it's tied to the time) through 360º of a circle.
game.TankXPosition and game.TankYPosition are the x- and y-coordinates of the object it is circling.
I hope this helps. Cheers!
Im also trying to do the same things as EdwardRHunter but unlike him I have no clue what that means what I should do! How would I implement these rules? Sorry for asking a stupid question there!
Comments
I've never actually done this...but it seems like it would work in theory.
_______________________
*** visit www.spiritApps.com to check out the Spirit Connoisseur Apps ***
(Rum and Vodka now available for 17+)
_______________________
Constrain Attribute: self.Position.X To: 160*cos(self.Time*200%360)+240
Constrain Attribute: self.Position.Y To: 40*cos((self.Time*400%360)+160
Constrain Attribute: self.Rotation To: vectorToAngle(240-self.Position.X,160-self.Position.Y)+90
160*cos determines the swing amount back and forth
40*cos determines the up and down amount
200 and 400 are the speed (I had to play around with these to make it work - for a little fund make them different amounts and see what happens)
+240 and +160 makes the center point of the screen (want it lower, make the +160 just +60 or something)
The +90 on the rotate is an offset for me to make my object be rotated how I wanted it.
Edit: Just opened up CodeMonkey's Example Rotations and there was self.Time. I bet everybody knew about it but me...
Now the trick is, how do I get the girl to grab onto the end of the rope and swing back and forth? And when she pushes jump, to let go?
lol
Okay, I'm not getting A3MG method to work. Butterbean, did you?
So what am I missing? Where is the motion coming in? I've tried using this exactly and nothing is happening.
</dense mode>
Hang On (Demo)
Cheers!
I can't dig into it until tomorrow, but I think that will do what I need.
Out of curiosity, is it possible to make a pendulum slow down and stop?
Edit: Oh, and we would have to decrease the '160' and '40' amounts (the length of the arc) as well.
I couldn't get the newer version to work smoothly, I'm afraid. I'm sure that there's a better way to achieve the effect you want; however, at this point, I don't know what it is.
Hang On 2 (Demo)
I'll also e-mail you a copy.
Cheers.
Cheers.
Example Rotations
Look at the behaviours in his Orbital actor where he constrains the x-coordinate of Orbital to:
60*cos( self.Time *300%360)+ game.TankXPosition
and its y-coordinate to:
60*sin( self.Time *300%360)+ game.TankYPosition
In these equations:
60 represents the radius of the circle (in pixels).
self.Time *300%360 is the angle. Here, it increments itself (because it's tied to the time) through 360º of a circle.
game.TankXPosition and game.TankYPosition are the x- and y-coordinates of the object it is circling.
I hope this helps. Cheers!