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

Move GameObject to new position overtime

I'm pretty sure that this is a rookie mistake which im looking over, but I need some directions. here is my code: void OnMouseDown() { if(clickedContainers.Contains(transform.parent.name)) //if the containerblock is in "up" state { …
Sten Martens
  • 61
  • 1
  • 6
0
votes
2 answers

Clamp gameobject to within borders while slowly following another along x and y

I am trying to make an air hockey game and I need to clamp the AI into a specific area whilst it follows the puck around the board when it's in its half. I thought the following code would work but I'm getting some weird behaviour from the paddle…
JonHerbert
  • 647
  • 1
  • 8
  • 23
0
votes
1 answer

Processing - Animation between two points

I am developing the below code. To give you a brief description, it is allowing the user to click on different points on the screen, then these mouse coordinates and positions are stored in an array and also seen on the screen. When the user clicks…
Xerlij008
  • 3
  • 3
0
votes
1 answer

Interpolation function in processing

I am new new to processing and I am trying to experiment with the lerp function in processing. Basically what I am trying to do is, click on different point on the screen, these positions are being stored in an array. when the user clicks enter, the…
0
votes
1 answer

Unity GameObject doesn't run smooth when moved a second time

So I have a script to move gameobjects around. When I move a gameObject one time it's smooth. But when I move it a second time the movement very slow and looks abit buggy. The first input in the movement script is the object, then the position it…
Sjoerd Brauer
  • 129
  • 1
  • 12
0
votes
1 answer

Multiple interpolations in P5js

I'm trying to create multiple interpolations in p5js and for that purpose I tried to re-create Ben Fry's Integrator class in javaScript. I realize that transition and conversion from processing to p5js is quite difficult so if this is not possible,…
wewelo welo
  • 99
  • 1
  • 6
0
votes
1 answer

Moving player horizontally while in lerp jump Unity C#

The code I have allows a player object to move around the circumference of a circle and then "jump" to the center of that circle. What I am trying to do is allow the player to continue their movement around the circle while jumping so that the…
Sage.VS
  • 59
  • 1
  • 6
0
votes
1 answer

LibGDX: Camera lerp shakes when approaching target

I am using an Orthographic camera using a ScreenViewport with "UnitsPerPixel" set to 0.333f and when I move the play and then stop, the camera catches up as expected but then starts shaking slightly and acting weird when getting close (around the…
vedi0boy
  • 1,030
  • 4
  • 11
  • 32
0
votes
3 answers

unity lerp scale doesn't work

I am trying to make an object scale from zero to it's normal size when I instantiate it, so it will look like it popped to the screen. So when the object start I get it's normal size then update it to zero, and then in update I am scaling it. This…
DramboHero
  • 1,043
  • 1
  • 12
  • 18
0
votes
1 answer

Unity C# Instantiate with GetComponent in Stack?

My idea was to create a Color lerp in my game. I have a stack, and each new spawned object should spawn with a different color. Sadly I don't know how to apply this in the stack. My code: private void ColorMesh(Mesh mesh) { Vector3[] vertices =…
ChrisD
  • 1
  • 2
0
votes
0 answers

Smoothing SKCameraNode motion using constraints

Question Is there a way to use constraints to smooth the motion of the camera? Detail I recently read a post about smoothing camera motion using linear interpolation (lerp) and it made me wonder if I could achieve a similar effect using constraints.…
squarehippo10
  • 1,855
  • 1
  • 15
  • 45
0
votes
1 answer

changing alpha levels while using color.lerp in unity5

I am using color.lerp on a sprite renderer to interpolate between yellow and red based on values I have in a dataset. I also want the transparency of the sprites to depend on the value so lower values will be more transparent. The color.lerp works…
Sockness_Rogers
  • 1,693
  • 3
  • 12
  • 23
0
votes
1 answer

Unity - How to animate platform move up and down on collision enter and exit using Lerp?

I am trying to animate a platform prefab that is spawned (the platform object itself is within an empty because its position changes) DOWN when a Runner object collides with it (onCollisonEnter) and UP on collision exit. I have followed answers…
blue
  • 7,175
  • 16
  • 81
  • 179
0
votes
2 answers

3D Vector linear interpolation

How can I lerp between two 3d vectors? I use this method for 2d vectors: public Vector2d lerp(Vector2d other, double speed, double error) { if (equals(other) || getDistanceSquared(other) <= error * error) return other; double dx =…
MCMastery
  • 3,099
  • 2
  • 20
  • 43
0
votes
1 answer

Lerp.localScale is not working OnTriggerEnter,Unity5.3.3,Gear VR App Dev

I am buliding a Gear VR APP,I want my character to scale down on entering the box collider zone,I can scale it down all of sudden by using transform.localScale = new Vector3(0.3F,0.3F,0.3F); But i want it to be done smoothly.Dont knw the reason why…