[SOLVED] About interpolate and constant speed

ModernMonkeysModernMonkeys Member Posts: 22
edited July 2014 in Working with GS (PC)

Hey guys,

So let's say I want to move an actor from point A to point B, only on the X axis, by using interpolate. Problem is, I need to put the actor on different X.position and every duplicates need to move at the same speed (kinda lika an endless runner movement).

I've searched the forums and found this equation based on speed = distance/time >>> time = distance/speed

Here's exactly what I did :

Interpolate : self.position.x
to : -100 (it is a fixed position that I used just to make sure the actors goes completly from right to left on the screen)
for : (self.position.x+100)/speed (I set the speed to 50)
Using a : linear function

So if an actor is 1000 px away from it's destination, it should take 20 seconds. If it's 2000 px away : 40 seconds.

What happens is weird thought. Every actor moves very slowly, then after a few seconds, they start to go at an incredibly fast speed near to teleportation. Looks like starships warping in star wars. Cool effect, but not really practical for platforms.

Anyone ever had this problem? Is there a problem in my equation?

I use windows version.
Thanks!

Comments

  • CodeCellCodeCell Member Posts: 90
    edited July 2014

    Hi hello,

    The issue here is that you can't use the actors self.position.x in an interpolate. That's why it is going super super fast. What you need to do is to create a new attribute (real) inside the actor and change it to self.position x. Then use that attribute in the interpolate.

    It's because as the actor interpolates, the actors x position is changing, and since it has changed, it changes the value of the formula in the interpolate.
    Hopefully that makes sense.

  • ModernMonkeysModernMonkeys Member Posts: 22

    Omg thanks!

    That is so obvious now that I see it.

    I had temporarily solve my problem by simply changing the destination to self.position.x-5000. Problem with this method is that I would need to change it every level since levels are never the same width.

    Funny how little details can create major "bugs" in game development...

  • CodeCellCodeCell Member Posts: 90

    Glad it worked out for you, your best of fixing your bugs or issues rather than finding temporary workaround :)

  • KickingBehindsKickingBehinds Member, PRO Posts: 49

    @CodeCell said:
    Hi hello,

    The issue here is that you can't use the actors self.position.x in an interpolate. That's why it is going super super fast. What you need to do is to create a new attribute (real) inside the actor and** change it to self.position x**.

    Can you please just clarify when you say "change it to self.position x", do you mean as a separate formula?

Sign In or Register to comment.