I’m following a tutorial (beginner) on first person camera movement and playercontroller scripts, this script is supposed to lock my player camera to an empty object in my player called CameraPos, but it doesn’t work. Unity isn’t coming up with any errors. What’s wrong? Any ideas would be appreciated.
here is the player camera script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCam:MonoBehaviour
{
public float sensX;
public float sensY;
public Transform orientation;
float xRotation;
float yRotation;
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
// get mouse input
float mouseX = Input.GetAxisRaw(“Mouse X”) * Time.deltaTime * sensX;
float mouseY = Input.GetAxisRaw(“Mouse Y”) * Time.deltaTime * sensY;
yRotation += mouseX;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
// rotate cam and orientation
transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);
}
}
And here is the Move Camera script (which isn’t working):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveCamera : MonoBehaviour
{
public Transform cameraPosition;
private void Update()
{
transform.position = cameraPosition.position;
}
}
