I need some help, I want to make my object move to another set xyz location when clicking the button I used transform.Translate but I don’t know how the object will stop to the target location .Thanks a lot! here my script:
using UnityEngine;
using System.Collections;
public class NextPosition : MonoBehaviour {
public GameObject objectToMove;
public bool move = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(move == true){
objectToMove.transform.Translate (50f,50f,50f);
}
}
void OnGUI(){
if (GUI.Button (new Rect (Screen.width * (.25f), Screen.height * (.8f), Screen.width * (.05f), Screen.height * (.07f)), "Next")) {
Debug.Log("Moving");
move = true;
}
}
}