Pendulum - how?
IsabelleK
Member, Sous Chef Posts: 2,807
I'm making a pendulum:
It's a big actor (both stone circle, and rope are the same actor), it's made that way that the empty end of the line is the middle of the actor.
I have a rule:
If rotation = 45
Interpolate rotation to -45
and
If rotation = -45
Interpolate rotation to 45
It works fine, but sometimes it doesn't choose the quickest way, but rotate around - almost 360 degrees. I just can't find any other simple solution, so it rotates like a pendulum.
Can anyone help me with this?
Thank you!
It's a big actor (both stone circle, and rope are the same actor), it's made that way that the empty end of the line is the middle of the actor.
I have a rule:
If rotation = 45
Interpolate rotation to -45
and
If rotation = -45
Interpolate rotation to 45
It works fine, but sometimes it doesn't choose the quickest way, but rotate around - almost 360 degrees. I just can't find any other simple solution, so it rotates like a pendulum.
Can anyone help me with this?
Thank you!
Best Answers
-
FloridaGames Posts: 328Try this:
Add a self.clockwise(boolean)
Rule: If self.clockwise is true:
rotate clockwise.
Otherwise: rotate counterclockwise.
Rule: If self.rotation = 45
Change attribute self.clockwise to true
Rule: If self.rotation = 315
change attribute self.clockwise to false -
RThurman Posts: 2,880@TheMoonwalls, @uptimistic
Imagine how much simpler all this will be when joints are implemented!
Here is a slightly simpler way of making a pendulum. It will be slightly less processor intensive (than the demo above) -- since its not trying to do verlet integration.
This demo also has the advantage of being able to adjust gravity and acceleration a little easier.
http://www.mediafire.com/download.php?l3mk2io3rzohir1
I sure hope joints come along soon!
Answers
@RThurman
Could you reshare the file? I will appreciate it a lot!
Anyway I'm sure @rthurmans logic was probaply the same anyway!
Lump Apps and My Assets
http://www.mediafire.com/download.php?e3zg477cekl764j
Although It is not exactly what I have in mind. I don't know why, but firemaplegames' file does not work in my gamesalad.
However, I came with equations like that for ipad landscape pendulum going through centre:
Constrain:
- self.position.x to 160*cos(self.time*200%360)+512
- self.position.y to 40*cos(self.time*400%360)+384
It works fine, however I can't figure out how to do so it could rotate according to it position.
I was thinking about vector to angle like (512-self.position.x, 384 - self.position.y) + offset, but I flips weird and simply does not work.
Any ideas?
Thank you for your support, best community ever.
Constrain Y to 40*cos( game.Time *400)+384
Constrain rotation to 40*cos( game.Time *200)
I've never worked out why people put %360 after the angle+multiplier ? I dumped it as from what I can see it's unneeded baggage.
P.S. your pivot point is a little weird, it's not fixed.
Quick demo:
http://www.mediafire.com/?271as5qtbzan797