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

How to convert lerp to cubic easing in?

I need to convert the following code from using lerp to using cubic easing in, but I don't know what to do with the returned float value from the cubic easing in function, because I'm using Vector3 instead of floats. Can someone please give me a…
Weeboo
  • 41
  • 5
2
votes
1 answer

Best way to Receive Consecutives Input calls?

I'm a beginner coder in Unity and, although I don't have much experience coding, I know that my code is a mess. So, here's the thing: I inserted a certain functionality that allows the player to Lerp from its position, to a "Object1" when I click…
2
votes
2 answers

JS | How to lerp rotation in radians?

function lerp(start, end, amt) { return (1-amt)*start+amt*end } This lerp function works perfectly with coords. I can easily lerp X from 1 to 10. But problems appear when it comes to rotation. The rotation of an object is in radians. It can be…
AnimateMe
  • 57
  • 7
2
votes
3 answers

Unity3D multiple UI Buttons change main camera position NOT SCENE

Using multiple UI buttons to try and change main cameras positions to different views. I don't want to change scene. I am looking at one object lets say a car, and I want to see the head lights, I want to click a button to move main camera to see…
2
votes
2 answers

Unity - Reversing Lerped Position Back to Original Position

My logic must be quite off here. Essentially, I have a loading bar, that when activated by a mouse hover, will have it's overlaying UI panel left position increase to give the loading effect. This works fine. The problem is with reversing the UI…
Sean
  • 515
  • 7
  • 17
2
votes
1 answer

How to spawn evenly spaced game objects and move them in a circular path?

I don't know why my code doesn't work as intended! when I put speed = 1, it works fine. But if I increase the speed, it doesn't work. I tried to use FixedUpdate too on the circle class, but it didn't fix the issue. I don't know what else I have to…
Wael ElSawy
  • 43
  • 1
  • 7
2
votes
3 answers

Mathf.Lerp misses final value

I'm using Mathf.Lerp to animate a circular progress bar. The progress bar is an image that has a property named "FillAmount": 0 means not filled 1 means filled Along with the Fill property "Radial 360", it acts somewhat like a clock. For some…
tmighty
  • 10,734
  • 21
  • 104
  • 218
2
votes
1 answer

Threejs lerp, lerpVectors work without animation

I am trying to move 10 meshes in different directions after some amount of time through functions lerp, lerpVectors. Both of them gave me the same result, they just teleported meshes in new positions without animation of moving there. Here is my…
Egor
  • 248
  • 7
  • 17
2
votes
2 answers

How to lerp back and forth between two values X,Y in a loop?

Using setInterval or RequestAnimationFrame, I'd like to get the progression value from lerping between X and Y. Assuming that X is 0 and Y is 1, I want to have 0 when it starts, 0.5 in the half, and 1 when finished. I'd like this to happen in a…
punkbit
  • 7,347
  • 10
  • 55
  • 89
2
votes
3 answers

Lerping Color using Event Trigger SetGazedAt in Unity

I'm using the cardboard sdk and I'm trying to lerp the color of an object when it is gazed at using the cardboard sdk for Unity. I'm using the lerping script below and it functions independently of the gaze when I attach it to the object, but it…
user808996
  • 179
  • 4
  • 15
2
votes
4 answers

how to move Camera smoothly in unity3D?

When I want to move Camera from origin position to destination position,it looks so stiff.So if it can set move speed accordding to offset,how to do ?
joi
  • 46
  • 1
  • 1
  • 4
1
vote
1 answer

Smooth crouching in unity

I am trying to get my character to crouch smoothly, which works when decreasing height, but when increasing the height back to the original, it’s much more ‘stuttery’. However, when I do this while moving, the transition is smooth ‘both ways’. How…
lunixd
  • 13
  • 4
1
vote
0 answers

How can I "lock" a LineRenderer and make it only follow one direction?

So I have two predetermined points and I want to draw a line between them. I don't have an issue with actually drawing the line or snapping it to final position, but I want to lock it in between the two points while it's drawing. At the moment, it…
Syz
  • 63
  • 4
1
vote
1 answer

How to create a camera that combines both forced movement and smooth player following

Context So I'm making a clone of Crossy Roads where the camera follows the player. It does some linear interpolation (Lerp) after moving, and the camera starts moving away from the player in the positive direction (x-axis until camera reaches to a…
Zeid Tisnes
  • 396
  • 5
  • 22
1
vote
0 answers

How do you interpolate a value that wraps around?

I'm making a game in JavaScript in which I need to interpolate the result from the Math.atan2 function (which wraps around at 180 degrees to -180 degrees). Currently I just a lerp function, shown below function lerp(a, b, t) { return a + (b - a)…
RKM
  • 43
  • 6
1
2
3
11 12