- Home /
 
               Question by 
               MichealL2004 · Dec 24, 2017 at 02:20 AM · 
                scripting problemscript.scripting beginnerscriptingbasicsscript error  
              
 
              3rd Person Camera to Rotate With the Player
I have a 3rd person camera script that can make the camera rotate around the player (a sphere), but when the camera rotates, my player's rotation stays the same. I need help!!
my script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ThirdPersonCamera : MonoBehaviour {
 public Transform lookAt;
 public Transform camTransform;
 private Camera cam;
 private float distance = 5.0f;
 private float currentX = 0.0f;
 private float currentY = 0.0f;
 private float SensitivityX = 10.0f;
 private float SensitivityY = 1.0f;
 private void Start()
 {
     camTransform = transform;
     cam = Camera.main;
 }
 private void Update()
 {
     currentX -= Input.GetAxis ("Mouse X");
     currentY -= Input.GetAxis ("Mouse Y");
 }
 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);
 }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                