Using qerp to dive in a curve

This forum is currently in read-only mode.
  • Hi all. I have a boss in my game who floats above the player. Simple. But I want him to be able to swoop down onto the player. Not so simple.

    I THINK I need to set a cubiccurve from the boss's original location, toward where the game predicts where the player is going to be (via approximate aim or something), along the point of where the boss is in relation toward the player, and end up twice the horizontal distance it took to travel (so using a lerp to find double the distance between where the boss was original and where he hit the trough of his swooping curve). The thing is... is that there are so many variables and things that I don't really understand.

    Here, I'll draw an example of what I want via Inkscape:

    <img src="http://www.newadventgame.com/aaron/ygroy/boss_curve.png">

    Where the blue triangle is the boss's original position, the green his dynamic position, the circle the player (or where the game approximates he's going to be), and the red triangle the place I want the boss to end up (twice the X distance from the original position of the boss to the player).

    Pwetty pwease?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:34fgei33]Qarp(a, b, c, x)

    Quadratic interpolation. Returns lerp(lerp(a, b, x), lerp(b, c, x), x)

    In your case, you want to extrapolate both X and Y position, where 'a' is the starting position, 'b' the player's predicted location and finally 'c' the ending position.

    'x' would be time it takes to complete the move. At 0 it will be at starting point and at 1 it will be at ending point.

    So...

    +Is Diving = 1
     > Set Boss.X to qarp(starting_x,target_x, ending_x,dive_time)
     > Set Boss.Y to qarp(starting_y,target_y, ending_y,dive_time)
     > Add TimeDelta to dive_time
    +dive_time is equal to or greater than 1
     > Set Diving to 0
     > Set dive_time to 0[/code:34fgei33]
    
    Something like that. Experiment with it!
  • really sorry to bump such an old post. but could you please make a quick example capx. please.

    this is something i really need but am having trouble with.

    have tried many times to get my head round it myself but to no avail

    thanks in advance

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