Orbiting an actor AND following mouse / finger gestures..

lbc4everlbc4ever Member Posts: 18
edited February 2012 in Working with GS (Mac)
OK so I had a look at this tutorial on orbiting a point in gamesalad..

(Great work Mr ShirtBooth, thx for the pointers)
Now I want to have my actor do this BUT also follow my finger as if I had constrained the rotation to mouse position X. In other words
I want the actor to stay in orbit but follow my gestures for direction and speed.. Am I making sense? It's done my head in this morning so I
thought I'd see what the hive mind has to say on the topic.

Any help is as always, hugely appreciated.
Thanks in advance :)
Lbc4ever.

Comments

  • LumpAppsLumpApps Member Posts: 2,881
    edited February 2012
    Constrain self. positionx to game.mouse.position x + (radius * cos(angle))

    Constrain self.position.y to game.mouse.position y + (radius * sin(angle))

    Should do it.

    The angle is a value going from 0 to 360. You can constrain use a constrain atribute for this: angle= self.time%360 (@tShirtbooth does the same thing in the video. My formula orde is a little different I believe)

    Ask if you don't understand some of the syntax.
  • lbc4everlbc4ever Member Posts: 18
    I'm going to go and have a crack at it now Ludwig.
    Will let you know how I get on.

    Many thanks :)
  • lbc4everlbc4ever Member Posts: 18
    Close but no dice..
    What I now get is my actor travelling diagonally up & down the screen (following mouse position x) and rotating around the centre (sun x & y) before carrying on in a straight line.
    I'd like the actor to stay within a certain radius of the "sun" and orbit left or right depending on how I move my finger.. I'm goin to carry on headscratching for a bit & get back to you.

    Thanks again.

    Lbc4ever.

  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @lbc4ever

    "I'd like the actor to stay within a certain radius of the "sun" and orbit left or right depending on how I move my finger.."

    What's defining whether the actor orbits left or right is the speed of the orbit (minus values = clockwise / positive values = counterclockwise) . . . so all you have to do is dynamically control the speed of the orbit with whatever control you want (your finger on the screen in this case).

    Assuming an initial speed of 200 (self-time * 200) and an iPad screen of 1024 pixels wide . . . and let's imagine our goal is to have the actor orbit at a speed -200 (200 clockwise) when your finger is on the far left of the screen and +200 (200 counterclockwise) when your finger is on the far right of the screen we should do the following . . .

    Constrain the actors X to 200 * cos ( self-time * ( ( Game - mouse position X divided by 2.56 ) - 200 ) ) + 512
    Constrain the actors Y to 200 * sin ( self-time * ( ( Game - mouse position X divided by 2.56 ) - 200 ) ) + 384
  • CloudsClouds Member Posts: 1,599
    . . . personally I would cheat and just do this:

    http://www.mediafire.com/?htx3slle7xd51ts

    . . . but then again I am a shallow cheapskate. :bz :bz :bz
  • lbc4everlbc4ever Member Posts: 18
    @ Ludwig... Wow!
    I will pillage that template and be sure to mention you in the game credits. Awesome.
    @ Tynan, thanks man, I can learn a lot from that before trying to get my head around more complex stuff.
    THis forum NEVER fails. I only look forwards to the day when I can repay the favour.

    Many, many thanks guys.

    Lbc4ever.
  • lbc4everlbc4ever Member Posts: 18
    PS : Tynan,

    That first post nailed it. Salute :)
Sign In or Register to comment.