Answers for "Smoothing Camera Scripting Unity"

C#
0

Smoothing Camera Scripting Unity

// Smooth towards the targetusing UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour
{
    public Transform target;
    public float smoothTime = 0.3F;
    private Vector3 velocity = Vector3.zero;    void Update()
    {
        // Define a target position above and behind the target transform
        Vector3 targetPosition = target.TransformPoint(new Vector3(0, 5, -10));        // Smoothly move the camera towards that target position
        transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
    }
}
Posted by: Guest on August-22-2021

C# Answers by Framework

Browse Popular Code Answers by Language