Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

Follow Game Object? (keeping set distance)

$
0
0
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" } }

Viewing all articles
Browse latest Browse all 536

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>