Relative Content

Tag Archive for unity-game-enginevector

Trying to make a smoothly rotating and moving camera

using UnityEngine; public class CameraFollow : MonoBehaviour { public Transform target; public float smoothingspeed_movement = 0.125f; public float smoothingspeed_rotation= 0.5f; public Vector3 offset; void FixedUpdate () { Vector3 desiredPosition = target.position + offset; Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothingspeed_movement); transform.position = smoothedPosition; Vector3 desiredRotation = target.eulerAngles + offset; Vector3 smoothedRotation = Vector3.Lerp(transform.rotation.eulerAngles, desiredRotation, smoothingspeed_rotation); transform.eulerAngles […]