You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
406 B
C#
24 lines
406 B
C#
2 months ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
|
public class AttachCamera : MonoBehaviour
|
||
|
{
|
||
|
Transform myTransform;
|
||
|
public Transform target;
|
||
|
public Vector3 offset = new Vector3(0, 5, -5);
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
myTransform = this.transform;
|
||
|
}
|
||
|
|
||
|
void FixedUpdate()
|
||
|
{
|
||
|
if (target != null)
|
||
|
{
|
||
|
myTransform.position = target.position + offset;
|
||
|
myTransform.LookAt(target.position, Vector3.up);
|
||
|
}
|
||
|
}
|
||
|
}
|