Hey gang, I've been looking around and trying to find away to make a trail of objects following a leader, (like of the old shooter games)
I have my ship moving and looking at its "Leader" how do I keep a SET distance between the 2 objects?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowtheLeader : MonoBehaviour {
public float FollowSpeed;
public float FollowDistance;
public Transform ObjectTouFollow;
// Update is called once per frame
void Update () {
transform.LookAt(ObjectTouFollow); // look at leader
transform.Translate(Vector3.forward * FollowSpeed * Time.deltaTime); // Move Forward
/// Keep distance as set distance "FollowDistance"
}
}
↧