[Solved] ...script a movement from A to B

0 favourites
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • Hi there,

    I have an object that I want to animate statically. I have a fish in a fishbowl that needs to swim to the left and to the right and back and forth for ever.

    Ideally it would be great to have him randomly drift up and down a little as well as left and right.. but most important is just knowing how to script an object to be able to go to a specific x/y coordinate and back to another. I think I can manage the flipping logic and all that.. its really just about how to tell

    My instinct was to use bullet, but that just wants go at a fixed speed and not care about location. I would really love to be able to use easing.. in and out.. so the fish isn't just moving at a fixed speed, but rather speeding up and slowing down as it turns around going back the other way.

    Thanks!

    Caleb

  • Sine behaviour is what you are looking for.

  • yea that does do the trick, but what about interpolating to specific locations?   this is a great simulation for the fishtank for sure, but i feel like this doesn't offer a lot of control.

    another situation that i though would be related to this was if i wanted to have the fish move over to one side and stop.. then maybe in a given condition, then move to another spot with easing in/out.

    I did apply the sign suggestion and it worked well, but i was wanting to have a little more control over other situations.

    Thanks!

    Caleb

  • You can do a lot with lerp (linear interpolation)

    I don't have an example at the moment, but there are many on the forum.

  • ok i'll search around for it.   I've never come across a behavior called that.   thanks for the tip! :)

  • lerp isn't a behaviour, it's an expression you can use.

    create an object and use this:

    every tick - object set x : lerp(object.x,1000,0.1)

    to see the effect.

  • I would use the stuff from the Platformer tutorial, Enemy Movement. Should work perfect for what you are trying to do.

    scirra.com/tutorials/253/how-to-make-a-platform-game/page-7

  • LittleStain, Ok I was able to make that expression work so yea that's very cool. I'll see what I can do with that now that i've seen it work.

    VictoryX that is a way to do it and that does give me some ideas, but it wouldn't allow me to slow down the object as it approaches the edge to trigger a turn around event.

  • To slow down the object as it approaches just reduce the movement speed every tick if distance between object and edge is below a certain value.

  • yea I really like the idea of using lerp because i really just want to say move HERE and give it an X and Y value and be done with it.

    Relying on colliders to trigger events does sound like a great idea like in the case of the platformer for sure. I have used similar approaches with GameSalad, but interpolating with easing is something that is also equally helpful

    Thanks for the great advise and feedback!

  • You could also have a look at the MoveTo behaviour, a third party plugin.

  • I'll check that out as well! That could be helpful.. but since the last post i made earlier, I tried to forge ahead with LERP and this is what I came up with. It's an old post because I was having internet trouble earlier before relocating.

    LittleStain, one other quick question with LERP. It seems like everything I do is very snappy.. very fast.. is there a way i can make the lerp transition/interpolation much slower?

    dropbox.com/s/vn7i0l81md6hvs3/LerpTest1.capx.zip project file

    part12studios.com/temp/Lerp

    click the blue box to make it move to the next location.. see how it jumps? I'd like to ease that to be much much slower.

    Thanks!

    Caleb

  • also yes I did check that plugin and it works great, That is a big help for sure. I'm surprised this isn't a standard behavior. Moving an object with some easing between two points is pretty basic and common stuff, but hey that's what plugins are for :)

    but i would still love to understand if its possible to make LERP moves slower and if so how would it best be achieved.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • More explanation about lerp can be found in this topic

    if you change the lerp value to a much lower one it will go slower.

  • LiteTween

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