- Home /
Question by
mrcreeks02 · Feb 13, 2021 at 02:16 AM ·
c#rigidbodyscript.camera-looklock-cursor
how do i make a 3D first person camera look script (rigidbody)
Code at its simplest form would be appreciated, thank you.
Comment
Answer by ShuaG · Feb 13, 2021 at 08:48 PM
here is a script from my first game that i made, it is from a tutorial so i didnt write it myself, hope this helps.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
// set these in heirarchy
public Transform target;
public Vector3 offset;
void Update ()
{
if (target == null)
return;
Vector3 newPos = target.position + offset;
//if activated doesnt follow player y axis
transform.position = newPos;
}
}