unity camera follow

public Transform player;

    public Vector3 offset;

    void LateUpdate()
    {
        transform.position = player.position + offset;
    }

4
3
A-312 69370 points

                                    using UnityEngine;

public class Level3CameraFollow : MonoBehaviour
{
    // camera will follow this object
    public Transform Target;
    //camera transform
    public Transform camTransform;
    // offset between camera and target
    public Vector3 Offset;
    // change this value to get desired smoothness
    public float SmoothTime = 0.3f;

    // This value will change at the runtime depending on target movement. Initialize with zero vector.
    private Vector3 velocity = Vector3.zero;

    private void Start()
    {
        Offset = camTransform.position - Target.position;
    }

    private void LateUpdate()
    {
        // update position
        Vector3 targetPosition = Target.position + Offset;
        camTransform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, SmoothTime);

        // update rotation
        transform.LookAt(Target);
    }
}

4 (3 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
camera follow player unity 3d script c# scripting unity camera follow player how to make camera follow object unity how to make camera follow player unity 3d unity camera follow script 3d how to make a camera follow an object in unity 3d unity camera follow rigidbody script camera follow player unity camera follow unity3D Unity camera follow rolling ball unity how to make a camera follow object unity camera follow editor camera player follow camera unity follow camera unity 3d how to make the camera follow an object unity camera follow in c# unity unity camera follow mouse unity 3d camera follow unity 3d camera follow player unity third person camera follow how to make a camera follow a player in unity unity camera follow player 3d how to make camera follow object with script unity 3d camera follow script unity camera follow unity 3d camera follow unity 3 unity follow camera script 3d camera script follow object unity camera follow unity 2d unity c# adding camera follow how to make the camera follow an object in unity how to make a camera follow an object in unity how to make main camera follow player unity unity scene camera follow follow camera how to make the camera follow the player in unity and be at top always 2d camera follow unity follow cam unity camera follow in camera follow element make the camera follow the player camera follow player unity c# camera follow player camera follow wew camera follow mscript unity Smooth script unity unity which update for camera foloow unity c# smooth camera follow best camera follow unity unity camera follow smooth camera follow script c# smooth camera script unity camera folow unity unity camera smooth follow unity camera follow player smoothly smooth camera follow smooth camera follwo camera to follow player unity smooth following camera follow camera unity camera follow unity simple follow camera script unity unity best camera follow unity camera follow player script how to make smooth camera following unity smooth camera script smooth follow camera unity smooth camera follow unity follow target camera script how to have camera follow player unity camera follow script how to make the camera follow the player in unity 3d smooth camera movement unity script unity how to make a smooth camera follow object unity simple camera follow script unity3d smooth follow unity camera follow player scipt unity follow camera camera follow character unity unity smooth camera follow lock camera to player unity camera following player unity simple camera follow script unity camera follow in unity cammera follow unity basic C# camera follow script unity camra follow scripts for unity camera follow script for unity how to get camera to follow player unity get camera to follow player unity unity c# camera follow camera follwing script unity unity smooth camera how to maeka following camera unity unity make camera follow player unity camera move with player make camera follow player unity unity camera follows player smooth following camera unity how to make a camera follow script in unity camera follow controller unity unity player camera script camera follow gameobject unity unity move camera with player how to add camera follow in unity how to make camera follow player unity unity camera follow script camera follow player unity how to make the camera follow the player in unity Camera follow player script unity good camera follow unity smooth follow unity follow camera script unity smooth camera following script unity Camera Follow Unity Script unity camera follow player camera follow script unity unity main camera follows player make camera follow player unity 3d camera follow script unity 3d unity camera follow camera follow
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source