Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// GameObject will follow target transform constantly.
- /// </summary>
- public class FollowTarget : MonoBehaviour {
- /// <summary>
- /// The target we are following.
- /// </summary>
- public Transform target;
- /// <summary>
- /// How fast we move towards target.
- /// </summary>
- public float speed;
- // Update is called once per frame
- void Update () {
- // set our position closer to target
- transform.position = Vector3.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement