Skip to content

Instantly share code, notes, and snippets.

@KRNKRS
Last active December 20, 2016 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KRNKRS/1a5dfdfd53c07c259f2b91d732ddf14e to your computer and use it in GitHub Desktop.
Save KRNKRS/1a5dfdfd53c07c259f2b91d732ddf14e to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AimFollow : MonoBehaviour {
private GameObject followTarget;
private Vector3 offset;
void Awake () {
followTarget = GameObject.FindGameObjectWithTag("Player").transform.FindChild("FollowTarget").gameObject;
}
void Start()
{
offset = this.transform.position - followTarget.transform.position;
}
void Update () {
this.transform.position = followTarget.transform.position + offset;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment