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

XNA c# Lerping -- Make 3d object follow another 3d object

I am making a game where an enemy AI follows a player 3d object. However, my enemy object spasms sometimes when following the player and freaks out. I think my issue may be somewhere in my dot product or my cross product math. Here is my code from…
0
votes
1 answer

C# and XNA -- How to make 3d model follow another 3d model using lerp

I am writing the enemy class of a 3d game I am making and am working on making the enemy follow the player. I want the enemy to basically rotate itself in the direction of the player a little bit every frame and move forward a bit every frame. I…
0
votes
1 answer

Animating Circle to Move Across Line

I'm using the lerp() function to move my circle across a line, but it isn't working. The circle always ends up on the line somewhere depending on what my amt parameter is for the lerp() function. If I put 0.5 for the amt then the circle is placed…
B. Boe
  • 107
  • 1
  • 2
  • 9
0
votes
2 answers

Tween time based on distance

I'm tweening several game objects (with LeanTween) and want the time to be shorter if the distance between distance points a and b are shorter. I used to write my own forumla for it years ago but forgot it (duh). Can somebody give me a hint? And is…
BadmintonCat
  • 9,416
  • 14
  • 78
  • 129
0
votes
3 answers

Unity3D C# Negative Lerp?

I am wanting to lerp the variable that controls my animations speed so it transitions fluidly in the blend tree. void Idle() { _agent.SetDestination(transform.position); //Something like the following line _speed…
Martin Dawson
  • 7,455
  • 6
  • 49
  • 92
0
votes
2 answers

Can I Use Processing 3 For Loop with If Statement for Animation Frames?

Script runs in Processing 3.0.1 editor. I want to achieve: continuous loop maintain for loop's value of 10 (where each new set of triangles in for loop replaces each oldest set making the animation appear as a flaming meteor) Can I accomplish…
user5556825
0
votes
1 answer

unity 2D how to move object between two positions

I have two possitions posA and posB i want to move my player between this two position on button click.using Vetor3.Lerp player move only one time but it didnt work second move.can any one help. using UnityEngine; using…
cain
  • 709
  • 2
  • 10
  • 18
0
votes
2 answers

Use Lerp Position and Slerp Rotation together (Unity)

This is what I try to do, When I click on a UI Element, the camera smoothly rotate (to look at the target) and simultaneously move on top of the target. To perform that I use a two Coroutine one for the Lerp Position and the other one for the Slerp…
Kyan
  • 103
  • 12
0
votes
3 answers

Vector3.Lerp not correctly working?

I am using Unity3d and I have Vector3.Lerp problem. In my initial code Lerp code working normal, but the second Lerp in PrevView method is not working correctly. Camera just shakes and returns to it's previous position. Where am I making…
user4589444
-1
votes
2 answers

Tilt camera when player moves left and right unity

I tried to implement this effect, similar to this: https://www.reddit.com/r/Unity3D/comments/12kn33e/i_added_camera_tilt_based_on_the_movement_of_the/, using Lerp to smooth out the camera tilts, but was only able to get it working "snappily", ie.…
lunixd
  • 13
  • 4
-1
votes
1 answer

How can I best calculate beats per min, given the time in between two beats?

I'm creating an app that tests how fast in beats a user can achieve with taps, mouse clicks / button pushes etc. Each time the user hits the button, I call this function, beat(); to calculate their current BPM and fill a graphic with that BPM. I…
NCarlson
  • 330
  • 2
  • 13
-1
votes
1 answer

C# Unity cannot implicity convert type float to int

I'm trying to animate the color of gameObjects that are referenced in array. like this public GameObject[] laneMat; void Update() { StartCoroutine(CountDownMat(laneMat, .3f)); } IEnumerator CountDownMat(GameObject[] laneMat, float…
Ashraf
  • 9
  • 2
-1
votes
1 answer

How is it possible to Lerp from a non initialized value to an initialized value?

I am confused how I can Lerp from inputDirection to targetInput when inputDirection has not yet been initialized, only defined. This piece of code is from a tutorial and I know it works, but I don't know why. My guess is that inputDirection is a…
Wonjae Oh
  • 33
  • 7
-1
votes
2 answers

how to update only once in unity

Hello i have a code which moves my main camera to other game objects positions when i press button like if i press button 1 it will move towards object 1 position same for button 2 and 3. Now in my code i have a boolean named as flag which is true…
Nouman Khan
  • 49
  • 2
  • 11
-1
votes
1 answer

Vector3.Lerp only performing first linear interpolation

I am trying to make a player spaceship move between three points when the user enters left or right on the keyboard. I would like the player to move smoothly between these points but it seems that the Lerp function is only interpolated once. Here…
Wp3Dev
  • 2,001
  • 7
  • 38
  • 54
1 2 3
11
12