28 lines
702 B
C#
28 lines
702 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace BNG {
|
|
public class FollowTransform : MonoBehaviour {
|
|
|
|
public Transform FollowTarget;
|
|
public bool MatchRotation = true;
|
|
public Vector3 offset;
|
|
|
|
public float YOffset = 0;
|
|
|
|
void Update() {
|
|
if(FollowTarget) {
|
|
transform.position = FollowTarget.position+offset;
|
|
|
|
if(YOffset != 0) {
|
|
transform.position += new Vector3(0, YOffset, 0);
|
|
}
|
|
|
|
if(MatchRotation) {
|
|
transform.rotation = FollowTarget.rotation;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |