How to make an object moves to a target, but keep moving after it reaches the target, I’ve tried moveToward, but it stopped when it reached the target…
sorry if my english is so bad
How to make an object moves to a target, but keep moving after it reaches the target, I’ve tried moveToward, but it stopped when it reached the target…
sorry if my english is so bad
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public Transform target;
public float speed;
void Update() {
float step = speed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, target.position, step);
}
}
Is this what you’re looking for? This just moves your object transform towards a target transform at a defined speed.
(Script from the Unity Docs)
bump. Still looking for an answer on this one.