hi,i have 3d model character with all control to move my character and i planned to move my character to some coordinate when i finish the level, so in finish level screen i want to show result and also my character in there, well i think it will be cool. i tried this but my character just not moving instanly to that location
var character : Transform;
function OnTriggerStay (theCollider : Collider) {
NotificationCenter.DefaultCenter().PostNotification(this,"endGame");
fixedPosition();
Destroy(this.gameObject);;
}
function fixedPosition(){
character.transform.position = Vector3(51,0,12);
character.Rotate(0,-110,0);
}
Hi
You can use Vector3.MoveTowards moving
// The step size is equal to speed times frame time.
var step = speed * Time.deltaTime;
// Move our position a step closer to the target.
transform.position = Vector3.MoveTowards(transform.position, target.position, step);
And Vector3.RotateTowards for rotating
var targetDir = target.position - transform.position;
// The step size is equal to speed times frame time.
var step = speed * Time.deltaTime;
var newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0);
Debug.DrawRay(transform.position, newDir, Color.red);
// Move our position a step closer to the target.
transform.rotation = Quaternion.LookRotation(newDir);