- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
el-santia93 · Sep 19, 2013 at 04:25 PM ·
mathf.lerp
Mathf.Lerp doesnt work well
Hi, in my game i instantiate various textures onto the scene and animate them along the X-axis with mathf.Lerp.This works fine for the first set that instantiates but the other sets dont animate. Heres my code
//
#pragma strict
var xStartPosition : float = -1;
var xEndPosition : float = 0.5;
var speed : float = 1;
private var StartTime : float;
function Start () {
StartTime = Time.deltaTime;
}
function Update () {
transform.position.x =Mathf.Lerp(xStartPosition,xEndPosition,(Time.time-StartTime)*speed);
}
Any help would be appreciated
Comment
#pragma strict
var xStartPosition : float = -1;
var xEndPosition : float = 0.5;
var speed : float = 1;
private var StartTime : float;
function Start () {
StartTime = Time.deltaTime;
}
function Update () {
transform.position.x =$$anonymous$$athf.Lerp(xStartPosition,xEndPosition,(Time.time-StartTime)*speed);
}
this is the code,didn't come out well before
Best Answer
Answer by meat5000 · Sep 19, 2013 at 04:33 PM
Instead of caching Time.deltaTime, cache Time.time instead.
Your answer
Follow this Question
Related Questions
Tracking a projectile with Mathf.Clamp 1 Answer
Limiting rotation in 2 axis' 1 Answer
Pausing a Mathf.Lerp 1 Answer
Mathf.lerp to increase intensity and range of pointlight 1 Answer
Checking a float during lerp 1 Answer