I’m currently working on a menu. And I need to get it to slide.
But my Lerp is working just like normal transform.position and I don’t really
know why. Heres the code I’m using! Any ideas?
var player : Transform;
private var fp : Vector2;
private var lp : Vector2;
var startp = Vector3(0,0,-5);
var pos1 = Vector3(5,0,-5);
function Start()
{
}
function Update()
{
for (var touch : Touch in Input.touches)
{
if (touch.phase == TouchPhase.Began)
{
fp = touch.position;
lp = touch.position;
}
if (touch.phase == TouchPhase.Moved )
{
lp = touch.position;
}
if(touch.phase == TouchPhase.Ended)
{
if((fp.x - lp.x) > 0.5) // left swipe
{
player.transform.position = Vector3.Lerp(startp, pos1, Time.deltaTime);
}
else if((fp.x - lp.x) < -0.5) // right swipe
{
player.transform.position = Vector3.Lerp(pos1, startp, Time.deltaTime);
}
}
}
}
That works yes, but when I try to convert It into the javascript and be affected only when i swipe, it still acts like normal transform.position
– BatzugaThanks @rutter, this helped me to understand better Time.detalTime and fix a bug. Cheers
– KevinKLVHello @rutter I also have a problem with Lerp, but I understood it differently. In a line such as: shopper.transform.forward = Vector3.Lerp(shopper.transform.forward, SceneIndex.instance.waypointTransforms[nextWayPoint].targetTransform.forward, 8f * Time.deltaTime What will happen? Thanks
– Eco-Editor