Using moveTo and sine together

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • I'm moving characters around using the MoveTo behaviour. When they are moving I want to make it look like they are hopping so I also use the sine behaviour to move them up and down vertically.

    When they arrive I use an "On Move To Arrived" event to stop them them hopping.

    However the arrived event isn't working a lot of the time. I think it's because they are also moving up and down due to the sine behaviour so they are not landing on the correct spot, sometimes for up to 8 seconds.

    Any ideas how I can use these 2 things together? Or a good alternative?

  • If your character is moving horizontally only, then instead of "MoveTo On Arrived" event you can simply compare X-coordinate. If Character.X=targetX, then it has arrived.

    You can use Tween instead of MoveTo. Tween will change X coordinate, and Sine will change Y.

    Another solution is to use a separate invisible sprite for character, with MoveTo, but without the Sine - let's call it CharacterBase. And you will have to set your visible Character sprite position on every tick to CharacterBase + Sine offset.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • They are moving any direction (360 degrees)

    You can use Tween instead of MoveTo. Tween will change X coordinate, and Sine will change Y.

    I tried this and it worked but didn't look as good as they would go different speeds depending on the distance

    If your character is moving horizontally only, then instead of "MoveTo On Arrived" event you can simply compare X-coordinate. If Character.X=targetX, then it has arrived.

    I tried this too as I figured it will still work but it was really hit and miss for some reason. I can't figure out why, may experiment with it more.

    Another solution is to use a separate invisible sprite for character, with MoveTo, but without the Sine - let's call it CharacterBase. And you will have to set your visible Character sprite position on every tick to CharacterBase + Sine offset.

    If I'm still having no luck I'll investigate this.

    Thanks for the great ideas!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)