How to get a touch rotated actor to keep rotating and gradually decrease speed?

ParthoPartho Member Posts: 3
edited January 2014 in Working with GS (Mac)
Hi guys!

A hard googling newbie here.
I've managed to get an actor, fixed in position, to follow touch input to rotate. It nicely follows the finger.

But how do I get it to keep rotating on release, in the same speed as the finger moved it, and in the right direction?
And after that, slow down and finally stop?

Would really appreciate some help


  • Braydon_SFXBraydon_SFX Member, Sous Chef, PRO, Bowlboy Sidekick Posts: 9,051
    edited January 2014
    To make it slow down, use the interpolate behavior:

    Interpolate self.Rotation to 0
    Duration: "X"

    X = a set time predetermined by you.

    EDIT: You may be able to modify this tutorial to track the speed of the dragged finger.
  • ParthoPartho Member Posts: 3
    Thanx a lot Braydon_SFX, I'll look into that.
  • ParthoPartho Member Posts: 3
    Some useful stuff in there above, but I can't figure out how to detect the direction of the rotation.

    Since it's a circular motion there probably is a way to do it by checking the and actors rotation angle and compare it to a previous value.

    If the first angle was say 100° and the next 90° the direction of rotation would be clock wise.
    But it's when the rotation passes 0° it gets tricky..

    Lets say the first angle check gives 255° and the following gives 5°. According to the previous logic this rotation also would be clock wise. This may be true, if it was a fast rotation of a total of 250°. But if the rotation actually was performed counter clock wise it passed 0° and then actually is counter clock wise.

    Any ideas how to solve this and I'll be a happy man.

    Then I also could use the angle difference to determine the sped of the rotation.

  • SocksSocks London, UK.Member Posts: 12,822

    If you use 'constrain self.rotation to self.time*100' then the 'angle' is always increasing, so you never suffer from the 0°-crossover-issue.

    (use whatever you want for the '100' part, it simply controls the speed / degrees per second).
  • ParthoPartho Member Posts: 3
    Thanks Socks.
    I get the idea. But my brain just can't wrap how I will incorporate that in the code making the actor rotating following touch. I already use a constrain self.rotation there.

    I really appreciate you guys effort helping me out and it frustrates me that all the help you already been giving me doesn't make me solve this.

    Here's a screen dump of the actors rules:
Sign In or Register to comment.