Hi, could you help me. I am definitely not a coder. I need to stop my object by time or distance (whatever). I hope it’s simple task for you guys. Here is a code:
using UnityEngine;
using System.Collections;
public class StartAnimation : MonoBehaviour {
public float speed;
public Vector3 direction;
void Update() {
transform.Translate (direction * speed * Time.deltaTime);
}
}
public float speed;
public Vector3 direction;
public float time;
public float distance;
public bool stopAfterTime;
public bool stopAfterDistance;
private float startTime;
private Vector3 startPos;
Thank you very much. It does work when I use stopAfter Distance. But I could not succeed with stopAfterTime. Looks like that the code sets the time delay before start moving an object. Or am I doing something wrong?