You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class CameraControl : MonoBehaviour {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float skyboxRotateSpeed;
|
|
|
|
|
public float smoothFollow;
|
|
|
|
|
|
|
|
|
|
public Transform player;
|
|
|
|
|
|
|
|
|
|
private Vector3 currentVelocity;
|
|
|
|
|
|
|
|
|
|
void Start() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Update() {
|
|
|
|
|
RenderSettings.skybox.SetFloat("_Rotation", Time.time * skyboxRotateSpeed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FixedUpdate() {
|
|
|
|
|
Vector3 camPos = transform.position;
|
|
|
|
|
Vector3 playerPos = player.position;
|
|
|
|
|
Vector3 newCamPos = Vector3.SmoothDamp(camPos, playerPos + new Vector3(0, 3, -4), ref currentVelocity, smoothFollow);
|
|
|
|
|
transform.position = newCamPos;
|
|
|
|
|
}
|
|
|
|
|
}
|