GameVsJam/3d Prototyp/Assets/Scripts/CameraScript.cs

37 lines
761 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraScript : MonoBehaviour
{
[SerializeField]
private Character _character;
[SerializeField]
private Camera _camera;
public float Distance = 5.0f;
void Start()
{
Vector4 position = new Vector4(0, 0, -Distance, 1.0f);
Matrix4x4 mat = Matrix4x4.Rotate(Quaternion.Euler(45, 0, 0));
_camera.transform.localPosition = mat * position;
transform.position = _character.transform.position;
}
// Update is called once per frame
void Update()
{
transform.position = _character.transform.position;
}
private void OnValidate()
{
Start();
}
}