Easing toward mouse position

I'm trying to make an actor quickly accelerate towards the mouse position, but I don't want it to accelerate past it and take 200 million years and 3 months for it to finally stop moving all over the place and stay in place. I want it to slowly ease to the mouse position and come to a nice stop and maybe wobble a bit before finally stopping (to add a dynamic feel). Does anyone know of a way to do this easily? I also don't want to have to use an interpolation behavior if possible, since I don't want it to ALWAYS take a certain amount of time for it to reach the mouse position, as it could either move too fast or too slow. Thank you!

Having trouble with your game? Sounds like a personal problem.

Comments

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

    @ADSentertainment said:
    I also don't want to have to use an interpolation behavior if possible, since I don't want it to ALWAYS take a certain amount of time for it to reach the mouse position . . .

    Constrain self rotation to vectorToAngle (mouse x - self x, mouse y - self y)

    Move / 0° / Actor / Speed magnitude (mouse x - self x, mouse y - self y)

    Hold on, I'll make a demo . . .

  • SocksSocks London, UK.Member Posts: 12,822
  • pHghostpHghost London, UKMember Posts: 2,342

    @Socks‌ -- Very smart!

  • ADSentertainmentADSentertainment Member Posts: 397
    edited September 2014

    Are you using one of the dev builds of Gamesalad by chance? It says that my Gamesalad can only use version 2.0 files and that yours is version 2.1.

    Having trouble with your game? Sounds like a personal problem.

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

    @pHghost said:
    Socks‌ -- Very smart!

    Yeah it's nice and simple too, and of course you can multiply, add to or divide the speed part to make the overall action faster or slower.

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

    @ADSentertainment said:
    Are you using one of the dev builds of Gamesalad by chance? It says that my Gamesalad can only use version 2.0 files and that yours is version 2.1.

    I'm not sure what a 'dev build' is, this was done with 12.4.

  • -Timo--Timo- Member Posts: 2,313
    edited September 2014

    another way is:

    constrain self.motion.linear velocity.X to 3*(game.mouse position.X-self.position.X)

    constrain self.motion.linear velocity.Y to 3*(game.mouse position.Y-self.position.Y)

    3 is speed and can be changed.

  • ADSentertainmentADSentertainment Member Posts: 397

    @Socks said:
    I'm not sure what a 'dev build' is, this was done with 12.4.

    Like, are you using a pro exclusive version of Gamesalad? Because mine is completely up-to-date, and your file can't open on mine because it basically says it's being used by a newer version of Gamesalad

    Having trouble with your game? Sounds like a personal problem.

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

    @ADSentertainment said:
    Like, are you using a pro exclusive version of Gamesalad?

    What is a 'pro exclusive version of Gamesalad' ? I wasn't aware there were 'pro exclusive' versions (or even 'dev builds') ? Did you try the method, did it do what you needed ?

  • ADSentertainmentADSentertainment Member Posts: 397

    @Socks said:
    What is a 'pro exclusive version of Gamesalad' ? I wasn't aware there were 'pro exclusive' versions (or even 'dev builds') ? Did you try the method, did it do what you needed ?

    Like a nightly build. I know that they do (or used to do) those, but they were for pro members only. Here, lemme show you what message I'm getting whenever I open it: photo ScreenShot2014-09-27at121628AM_zpsada43b23.png

    Having trouble with your game? Sounds like a personal problem.

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

    @ADSentertainment said:
    Like a nightly build. I know that they do (or used to do) those, but they were for pro members only . . .

    Ok ? So I did it with an exclusive-Pro-dev-nightly-build (which GS no longer make) that only I, as a non-Pro user, have access to, sounds like a reasonable theory to me :smile: I can sell you a copy of this secret version if you like ?

    Did you try the method I posted ?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited September 2014
  • ADSentertainmentADSentertainment Member Posts: 397

    @Socks said:
    Did you try the method I posted ?

    Wait wait wait, whaaa. Weren't you previously a pro member though? I could have sworn you were before!

    Having trouble with your game? Sounds like a personal problem.

  • ADSentertainmentADSentertainment Member Posts: 397

    @RThurman, I actually used @timolarpe1998's example, although I might eventually take a look at Socks'. @Socks, did your example actually make the actor rotate while moving? I inputted what you put on the forums to see for myself, and it showed it doing some rotations, which was kinda obvious due to you using the rotation attribute.

    Having trouble with your game? Sounds like a personal problem.

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

    @ADSentertainment said:
    I actually used @timolarpe1998's example, although I might eventually take a look at Socks'. @Socks, did your example actually make the actor rotate while moving? I inputted what you put on the forums to see for myself, and it showed it doing some rotations, which was kinda obvious due to you using the rotation attribute.

    Ok, so you tried the method I posted, you saw the actor rotating, which you concluded was obvious given it effects the rotation attribute, so your question is does my example make the actor rotate (this is the actor you saw rotating) ? And you've yet to try my example (the example that you've just said you've tried) but you might eventually get around to taking a look at it, lol :D

    I'm not sure how to answer all that, but yes the actor does rotate, although I'm not 100% sure as I've not seen or read this thread yet :p

    I think I need more coffee :wink:

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

    @ADSentertainment said:
    Wait wait wait, whaaa. Weren't you previously a pro member though? I could have sworn you were before!

    Yes, I was a Pro member before, and one day I plan to be again, but right now I am not.

  • pHghostpHghost London, UKMember Posts: 2,342

    @ADSentertainment said:
    Like a nightly build.

    You need to be on the latest Release Candidate, that is 0.12.6, or at least on 0.12.4

    Those can be downloaded even by non-PRO members.

  • ADSentertainmentADSentertainment Member Posts: 397

    @pHghost‌
    Do I have to redownload it? Because I tried looking for updates on Gamesalad, and it said I was up to date

    @Socks By rotate, I mean does it rotate in such a manner similar to a plane when moving? I just wanted to be clear

    Having trouble with your game? Sounds like a personal problem.

  • pHghostpHghost London, UKMember Posts: 2,342

    @ADSentertainment‌ -- that might be caused by the Stable being switched to an RC...what version does it tell you it is? That's the easiest way to find out. The error you are getting makes it look like you have an older version.

    Go to: GameSaladRC > About GameSalad and it will tell you the version in the corner.

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

    ks By rotate, I mean does it rotate in such a manner similar to a plane when moving? I just wanted to be clear

    Did you try it, it's two behaviours, just try it out and see if it's what you need.

Sign In or Register to comment.