Questions tagged [lerp]

Lerp is a function which Interpolates between two values in a specific time `t` to create smooth animations.

Linearly interpolates between two vectors.

Interpolates between a and b by t. t is clamped between 0 and 1. It is used to create smooth changes of all type of ui controls. Changing the Audio, a Color or transform values of an game object in unity3d can be done with Lerp easily.

Documentation

170 questions
1
vote
1 answer

Unity C# Position Slerp is curving?

I've got some code that moves the players in increments of 10 on the x and z axis using a slerp. However, the current slerp setup is slightly off. For example, if my start position is (10, 1, 0), and my end position is (20, 1, 0), during the slerp…
Chris W.
  • 21
  • 1
1
vote
1 answer

How to tween/Lerp between two numbers

I want to be able to lerp between two numbers (Actually RGB). Sort of like a slider. Where 0 = (255,0,0), and 1 = (0,255,0). Is there any way to code with without an external library or function? Thanks.
1
vote
1 answer

Moving object to targets within an array on the canvas

I have some P5js code that I made. It basically moves the circle around the screen to predetermined targets stored in an array. I will be using it within my game that uses A* pathfinding and stores the path points in an array. I then am looking at…
Aaron
  • 121
  • 11
1
vote
1 answer

How can I add a colour gradient feature to my bresenham line drawing algorithm?

I've found this thread on StackOverflow but my python understanding isn't that good to properly translate it to C, I'm trying to add that gradient feature to this line drawing algorithm: #define sign(x) ((x > 0)? 1 : ((x < 0)? -1: 0)) x = x1; y =…
MiguelP
  • 416
  • 2
  • 12
1
vote
1 answer

How to use an exponential easing function while using Transform.RotateAround?

I have a scene where a cube-shaped object "rolls" on a flat surface. Each time, it completes a 90-degree rotation around pivotPoint (the edge making contact with the surface) over the pivotAxis (perpendicular to the direction of movement). For this,…
mgackowski
  • 13
  • 4
1
vote
0 answers

How do I fix my code such that the linear interpolation doesn't cross over?

I'm trying to make an infinite marquee (scrolling horizontal text), but on scroll it speeds up the translation of the HTML elements. I am achieving this effect by using a linear interpolation function. You can see the effect on this site that I'm…
awawawaw
  • 175
  • 3
  • 11
1
vote
2 answers

Mathf.SmoothDamp takes longer than it should inside a coroutine

I'm trying to move and rotate a gameobject inside a coroutine to smoothly reach a target position. To do this I tried using Mathf.SmoothDamp() to calculate a factor, which I use in a lerping function. This is my method: private IEnumerator…
Wojtek Wencel
  • 2,257
  • 6
  • 31
  • 65
1
vote
1 answer

How to let a rectangle rotate around MouseX, MouseY in Processing

I am trying to lerp the positions of items in Processing. So that item one moves to item two with a little ease. In my code I have a small red rectangle and want to lerp its position to the green rectangle while key "x" is pressed. The green…
Cyrill
  • 833
  • 2
  • 6
  • 16
1
vote
2 answers

How to interpolate a value in one range into another

I have 2 double values which can go from let's say start value 62.243 to end value 79.495. I have another 2 double values which can go from let's say start value 4.456 to end value 7.687. double start_1 = 62.243; double end_1 = 79.495; double…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
1
vote
1 answer

Unity Viewbob using lerp snaps back for 1 frame at random

I have a problem with my ViewBobScript, it snaps back to the lerps start position for 1 frame. Here is a Recreation/Video of my problem: (Due to the framerate of the video not matching up to the game it might look as if the lerp is not smooth, while…
jazzhar
  • 33
  • 5
1
vote
1 answer

(Three.JS) How to loop lerp scene background colors?

as the title says, I'm trying to smoothly transition between multiple colors. (Day, Sun Rise/Set, and Night,), and have these colors as the background for my scene, essentially, I'm trying to make a Day/Night Cycle. Is this possible? If so, how? I'm…
Fox GAMING_NTF
  • 153
  • 2
  • 14
1
vote
2 answers

Moving Maincamera slowly to another position

I want to move main camera slowly from one point to another point when a button is pressed. This button calls the method which has the code to move the camera. I have tried using the Lerp method but the camera position is changing so fast that when…
sam
  • 127
  • 1
  • 5
1
vote
1 answer

Unity fill amount lerp

Trying to lerp image fill amount from this script. public class ProgressBar : MonoBehaviour { public static int minimum; public static int maximum; public static int current; public Image mask; void Update() { …
Kira Angelic
  • 15
  • 1
  • 6
1
vote
1 answer

How to make a lerpColor() function without ProcessingJS

I would like to create my own lerpColor(c1, c2, amount) function, with the same output as the one in ProcessingJS http://processingjs.org/reference/lerpColor_/ I am looking or something like this: lerpColor = function (c1, c2, amount) { // Do…
user13605748
1
vote
1 answer

Mathf.PingPong from 1 to 0

I have created a helper to PingPong from 1 to 0, but I'm having a hard time inverting this, so that the value goes from 1 to 0. Below you can see the code, I'm currently using. I'm also not sure if this is even possible. _lerpPulse =…
Quincy Norbert
  • 431
  • 1
  • 6
  • 18
1 2
3
11 12