Afternoon, I'm still learning to code in unity C# or JS (by using tutorials & things i have leaned on the way) getting more understanding with things ect... (Not sure if this code is all wrong tbf) but basically what i'm trying to do is make it like any other 3rd person camera, atm this script only rotates around the player & everything then goes invented as the player only goes 1 way but camera goes around the player kinda thing is there any tutorials how to do 1 or able to do quick script 4 me? The script i have connect to my camera & then linked to my player is below (C#) Thank you for your time Luke Code (CSharp): using UnityEngine; using System.Collections; public class ThirdPersonCamera : MonoBehaviour { private const float Y_ANGLE_MIN = 0.0f; private const float Y_ANGLE_MAX = 50.0f; public Transform lookAt; public Transform camTransform; private Camera cam; private float distance = 10.0f; private float currentX = 0.0f; private float currentY = 0.0f; private float sensivityX = 4.0f; private float sensivityY = 1.0f; private void Start() { camTransform = transform; cam = Camera.main; } private void Update() { currentX += Input.GetAxis ("Mouse X"); currentY += Input.GetAxis ("Mouse Y"); currentY = Mathf.Clamp (currentY, Y_ANGLE_MIN,Y_ANGLE_MAX); } private void LateUpdate() { Vector3 dir = new Vector3 (0, 0, -distance); Quaternion rotation = Quaternion.Euler (currentY, currentX, 0); camTransform.position = lookAt.position + rotation * dir; camTransform.LookAt (lookAt.position); } }
Take a look at the Unity Standard Assets. It has a basic third person camera controller. You can use this as guidance.
I Made A Switch Camera View Script From First Person To Thrid Person But I Don't Know If This Is What You Want...