Quantcast
Channel: Questions in topic: "moveto"
Viewing all articles
Browse latest Browse all 116

Use Vector3.Lerp to move an obj without slowdown

$
0
0
Hi. I try to use part of code i found on the forum, to move an object to a predetermined point(i use another gameobject). The gameobject seems to be move correctly, but the linear movement without the "slowdown" dosen't work. the object run fast at the beginning but when is close to the endPoint (the other GameObject), have a slowdown. this is my Code: shoanim : Transform; // my actor. target : Transform; // the gameObject use for the endPoint. function Start(){ moveTo(shoanim , shoanim , target , 400); } function moveTo(thisTransform : Transform, startPos : Transform, endPos : Transform, time : float){ var i = 0.0; var rate = 1.0/time; thisTransform.rotation = endPos.rotation; while (i < 1.0) { i += Time.deltaTime*rate; thisTransform.position = Vector3.Lerp(startPos.position, endPos.position, i); yield; } print ("I'm at the same place as the other transform!"); } thank you for anyone help me

Viewing all articles
Browse latest Browse all 116

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>