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
0
votes
2 answers

How to double the lenght of a 2D array in C#

I have an array test {1, 2, 4} and want to pass it in a function IncreaseResolution(float[,] origin) which should increase the length of the array. So basically I want to turn test {1, 2, 4} into test {1, 1.5, 2, 3, 4}. So what I want to do is take…
Anonym
  • 7
  • 2
0
votes
1 answer

Smooth 2d rotation in unity

I'm trying to get an object to rotate smoothly on the z axis when it comes into contact with a collider. However it just seems to snap really quickly and I can't find a way to smooth this out. I've split the rotation out into 2 scenarios - one for…
MarkHughes88
  • 591
  • 3
  • 11
  • 25
0
votes
1 answer

lerpColor on objects with Processing

I am currently working on creating a kind of drawing tool with processing, in which black ellipses are drawn with the mouse pointer, which after some time fade away completely to white - i.e. are no longer visible. The whole thing could look like a…
Cyrill
  • 833
  • 2
  • 6
  • 16
0
votes
2 answers

Vector3.Lerp won't move my object despite my debugging saying it should

So this is for an aim-down sight motion in a FPS game. When the player right clicks, this coroutine is fired up which should move the player's right hand from its "idle" position to its "aiming" position. Once the aiming position is reached, hitbox…
BasuKun
  • 31
  • 4
0
votes
2 answers

Using the lerp function (Processing) to change position

+++ EDIT +++ I have a grid of individual rectangles. Now I want to move each of the individual rectangles with the Lerp Function to a new position (currently MouseX, MouseY). So far I only manage to lerp the grid as a whole – with an unwanted…
Cyrill
  • 833
  • 2
  • 6
  • 16
0
votes
0 answers

How do I use lerp correctly, making sure it reaches the target value

I am trying to create a player in love2D, and I have a lerp function that brings the players speed to 0 , but I know I am not using the lerp function correctly because it never reaches the end value and starts acting funky and crazy, how do I use…
Dragon20C
  • 307
  • 2
  • 11
0
votes
1 answer

How do I smoothly clamp controller input?

I'm trying to rotate an object according to the stick input on a controller, and then clamp it at a maximum rotation. When I use Mathf.Clamp() the rotation just hits that wall, and it doesn't feel good. I've tried using Mathf.SmoothDamp() as well…
0
votes
1 answer

How to use easing inside a coroutine to change a float value?

I would like to increase the value of a float over time but with added In-Out easing. Here I'm using Mathf.Lerp and I know there is Mathf.Smoothstep but in SmoothStep, I can't seem to control the speed of the easing itself. I would like the easing…
Abdo23
  • 77
  • 7
0
votes
1 answer

Move an object to another object with Lerp if the distance between them becomes too far in Unity

I want to move a cube A to another cube B using Lerp, but only if the distance between them is greater than 2.0f. But since Lerp is applied in multiple Update() frames, in the next Update() the distance between the two cubes is 1.9 for example, and…
kannaMain
  • 11
  • 3
0
votes
1 answer

How to add smooth movement to my java game?

my goal: in something like the pong, key controls should move bats smoothly. expectation: want the bats to move smoothly up or down with keys. actual results: bats move like lagging or change in speed. I tried using velocity vars with maybe lerp,…
Hyperb
  • 1
  • 2
0
votes
0 answers

THREE.js Using lerpColors to make Gradients

I've been trying to figure out some things re .lerpColors() - specifically if it's possible to transition between more than just 2 colors. I quickly put together a little app - the code is below and it works 100%, creating a nice smooth transition…
Sirab33
  • 1,247
  • 3
  • 12
  • 27
0
votes
1 answer

C#/Unity Time.deltaTime makes lerping Camera Follow jump

I recently posted a problem with a jittering Camera Follow in my 2D Game made in Unity, which was solved here. However after some time I noticed, that I am still getting jumps. I now know, that the problem lies in the lerp method of my camera…
jackjoe85
  • 1
  • 1
  • 2
0
votes
1 answer

Lerp not smooth when velocity changes abruptly

I have a object that moves at a variable speed. It can reach from 0 speed units up to N speed units. I'm lerping the camera angle to rotate and look at the object smoothly and nice, like this: camera.eulerAngles = Vector3.Lerp(initialAngle,…
Daniel
  • 7,357
  • 7
  • 32
  • 84
0
votes
1 answer

interpolate a given array to be in new lenght

in order to interpolate 2 values, I can use lerp(int a, int b) { return (a + b) / 2; } Now imagine I've an array(1, 30, 100, 300) and I want to interpolate it to array in size N (N=10 for example). If N == 7, then: 1,15,30,65,100,200,300 I've…
Maor Cohen
  • 936
  • 2
  • 18
  • 33
0
votes
1 answer

Equivalent of 1D numpy.interp in C++ Cuda (Lerp in CUDA)

I have two vectors 'xp' and 'fp' which correspond to the x and y values respectively of the data. A third vector 'x' which is the x coordinates at which I would like to evaluate the interpolated values. My results in python using NumPy's interp…
Vishnu
  • 499
  • 1
  • 5
  • 23