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

Controlling arc axis with Vector3.Slerp

I'm using Vector3.Lerp() to instantiate some prefabs at a set distance from each other. This works, but I've just started playing with Vector3.Slerp. This creates a nice arc, however I'd like the arc to happen on either the X or Z axis, not the Y. …
Tony
  • 3,587
  • 8
  • 44
  • 77
1
vote
5 answers

Lerp with Time.deltaTime

I have a question about Lerp. So I know that lerp helps you to move your object like: void update(){ transform.position = vector3.lerp(start.position,end.position, (Time.time / 1000)); } this will get your object to your endposition. But if you…
Gmunderos7
  • 11
  • 1
  • 1
  • 6
1
vote
0 answers

Smooth camera follow after lerping object

I have a server-reliant multiplayer Unity3D game, where the server is written in Node.js. The server sends updates to the positions of players, and the players lerp to those positions on the client to simulate smooth movement. I am not using Unity…
daniel metlitski
  • 747
  • 3
  • 11
  • 23
1
vote
1 answer

Choppy camera movement with smooth follow

I am seeing a camera stutter when using smooth follow to lerp after my player with my camera in my multiplayer browser game. The player position is received from the server, the player lerps to that position, and my goal is for the camera to…
daniel metlitski
  • 747
  • 3
  • 11
  • 23
1
vote
3 answers

Vector3.Lerp is not working

I'm trying to smoothly move from my current position to a new position that I've hard coded but even using the Vector3.Lerp and Vector3.MoveTowards it's just moving the player normally without any delay effect. I have also tried to add…
pijushmandal
  • 13
  • 1
  • 3
1
vote
1 answer

Unity - how to lerp while a certain animation state is on?

Ok, so I have an animationnthe speed of which is controlled by user's tapping m meaning I cant just lerp for a set time but have to have it depend on if this is true: cameraAnim.GetCurrentAnimatorStateInfo (0).IsName ("stillOpening") By the end of…
blue
  • 7,175
  • 16
  • 81
  • 179
1
vote
2 answers

How can I transform 3 objects to swap positions, but make sure they aren't moving to a position an object is already going to?

I have applied a code to 3 objects. So far this code switches three cups around so that they swap places. The code gets the start position of the cup, and then the end position of each cup. All 3 end positions are actually the start positions of the…
Nicole Pinto
  • 364
  • 1
  • 22
1
vote
2 answers

Why is a lerp function written like this: (1 - bias) * start + bias * end;

I've seen a couple of lerp functions, mainly for lerping vectors, and they seem to go like this: vector lerp(float bias, vector start, vector end) { return (1-bias) * start + bias * end; } Whereas my naive way of doing it would be: vector…
Zebrafish
  • 11,682
  • 3
  • 43
  • 119
1
vote
1 answer

Smoothing walk animations in unity (2D Unity in C#)

So what we're trying to do is have smooth movement for our player character as they walk. The walk is dictated by user input via arrow keys. She's got an animation class and a collider class attached to her to keep her walk cycle going and keep her…
1
vote
1 answer

Linear Interpolation Optimization For Sign-ness

In a tight loop, I am doing a linear interpolation between two floating point values. However, the only necessary part of the result is the sign (whether the result is negative or positive). I'm doing a typical lerp operation right now, f way…
user1043761
  • 696
  • 6
  • 22
1
vote
1 answer

Unity Color.Lerp "laggy"

I want to lerp the start color of two particle systems from one color to another in Unity if the player enters a triggerzone. I tried to do it with Color.Lerp but the result is that it lerps "laggy", meaning it has only 3 colors inbetween. My…
KonfuPanda
  • 17
  • 4
1
vote
3 answers

Unity - Looking through the scope of a gun

Right now I have 2 Cameras: the main camera displays the gun at its normal state and a second camera is attached to the gun (the gun is a child of the main camera) and when toggled it looks through the scope of the gun and increases the field of…
Kyle Jensen
  • 419
  • 9
  • 27
1
vote
1 answer

Quaternion.Lerp doesn't rotate object with exact degrees

I want to rotate my object 90 degrees with Quaternion.Lerp when user press the upArrow. But after each rotate I can see that it does not rotating my object exactly 90 degrees. approximately 88 degree it rotates. What is the problem? How can I solve…
Cenkisabi
  • 1,066
  • 8
  • 25
0
votes
2 answers

I´m trying to use Vector3.Lerp in unity2D to open moving pipes but it doesn´t work on the x axis

As mentioned previously, the code supposed to keep the pipes (called Top and bottom) moving while they are opening doesn´t seem to do anything but snap them right into the desired eventual position, with no animation Here's the full code of this…
0
votes
2 answers

My Lerp function only works one way but not the other way

I have a dynamic FOV and crouching script for my player which both use the Lerp function for smooth camera movement, but it only works for the increase in FOV and decrease in height. When the FOV and height return to normal, it just snaps back…
lunixd
  • 13
  • 4