How do I stop lerp?

0 favourites
  • 3 posts
From the Asset Store
Control your space ship in a weird space-time environment and destroy as many enemies as you can!
  • Hi, I wanted to know how to stop the camera lerp, using this post construct.net/en

    Setting:

    X: lerp(Self.X, Player.X, 0.03)

    Y: lerp(Self.Y, Player.Y-150, 0.03)

    To

    X: lerp(Self.X, Player.X, 0.00)

    Y: lerp(Self.Y, Player.Y-150, 0.00) when the player is greater than x position. With no hope, any help on how to stop the camera's movement when the players x is greater than x position.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Couldn’t you just compare the x position first?

    Player x < 800

    — set camera x to lerp( self.x, player.x, 0.01)

    Or I guess you could also add an else after that to lerp to the x boundary

    Else

    — set camera x to lerp(self.x, 800, 0.01)

    Or you could utilize the min() expression to keep it in the every tick. May not be as flexible later, and could be harder to read.

    Every tick

    — camera: set x to lerp(self.x, min(player.x, 800), 0.01)

    If you want a left boundary instead, use max() instead. If you have a left and right boundary, use clamp() instead:

    Lerp(self.x, clamp(player.x, 50, 800), 0.01)

  • Thanks so much

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