How to have static actor rotate and always face direction of swipe

AtomicFXAtomicFX Member Posts: 23
edited September 2014 in Working with GS (Mac)

Hey guys, I have an actor who's position does not move. There are other enemy actors that move towards him. By touching the static actor and swiping in the direction of the other actors a projectile is thrown at the attacking actors. What I want to do is have the static actor rotate and always face in the direction of the swipe. Does anyone know how I can go about doing this?
Thanks!

Answers

  • agueisagueis Member Posts: 420

    The actors that swipe to the acto who rotate are swiping from the left and from the right ?

  • AtomicFXAtomicFX Member Posts: 23

    The enemy actors are moving down the screen towards the main actor. The main actor is at the bottom and when you touch him and swipe in the direction of the enemy, it shoots a projectile at them coming from the main actor's location. I just need the main actor to always rotate and face the direction of the projectile (swipe).

  • SocksSocks London, UK.Member Posts: 12,822
    edited September 2014

    @AtomicFX said:

    At the start of the swipe record the finger position into two attributes (start X and start Y).

    So, when actor is touched, change start X to mouse X, change start Y to mouse Y.

    Then a fraction of second later (adjust timing to taste) record the current finger position into two new attributes (end X and and Y).

    So, Timer, after 0.1 seconds change end X to mouse X, change end Y to mouse Y.

    Then constrain the rotation of the actor to:

    Vector To Angle (end X - start X, end Y - start Y)

    You can also use the same info (end X - start X, end Y - start Y) to work out the magnitude (how far your finger has travelled in that time), so you could have the speed of the bullets effect by how fast you swipe if you wanted to.

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

    Quick (and terrible ! :) ) demo . . .

    Link: https://www.mediafire.com/?glec6xmn48jpltt

  • AtomicFXAtomicFX Member Posts: 23

    @Socks said:
    You can also use the same info (end X - start X, end Y - start Y) to work out the magnitude (how far your finger has travelled in that time), so you could have the speed of the bullets effect by how fast you swipe if you wanted to.

    YES!! That worked perfectly. Thanks for your help!

Sign In or Register to comment.