Pendulum - how?

IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
edited August 2012 in Working with GS (Mac)
I'm making a pendulum:

image

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

  • FloridaGamesFloridaGames Posts: 328
    Accepted Answer
    Try 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
  • RThurmanRThurman Posts: 2,880
    Accepted Answer
    @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

  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    edited August 2012
    Thanks @uptimistik, and @RThurman!
  • patrykadaspatrykadas Member Posts: 24
    Hi!

    @RThurman

    Could you reshare the file? I will appreciate it a lot!
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    FMG made one about 2 years ago, a pendulum template for the creator that is; unfortunately we can't access those the templates.

    Anyway I'm sure @rthurmans logic was probaply the same anyway! :)
  • patrykadaspatrykadas Member Posts: 24
    So is there anywhere a file I could use to know that logic?
  • LumpAppsLumpApps Member Posts: 2,881
    Here is the file, credits go to @firemaplegames
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Here is the requested file. It will be somewhat different from the very excelent FMG method given above.
    http://www.mediafire.com/download.php?e3zg477cekl764j
  • patrykadaspatrykadas Member Posts: 24
    Hello and thank you for your replies!

    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.


  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2013
    . . . but firemaplegames' file does not work in my gamesalad.
    Same here, I just get some flashing boxes.
    It works fine, however I can't figure out how to do so it could rotate according to it position.
    Constrain X to 160*cos( game.Time *200)+512
    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.
  • SocksSocks London, UK.Member Posts: 12,822
    Yep, just tested, those numbers work:

    Quick demo:

    http://www.mediafire.com/?271as5qtbzan797
  • patrykadaspatrykadas Member Posts: 24
    Wow, those indeed works great. Thank you!
Sign In or Register to comment.