- Home /
Question by
Cptenglish · Dec 31, 2021 at 05:40 PM ·
camerafpscamera rotatefps controller
First Person Camera looking down
I was following a tutorial for first person character controller from brackeys however I realised that every time I press the start button the camera would automatically look at the players feet instead of forward or where ever the camera was originally pointing at. So far I have no idea how to fix it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mousecontrol : MonoBehaviour
{
// Start is called before the first frame update
public float mousecontrolX;
public float mousecontrolY;
public float mousesensitivity = 100f;
public Transform player;
private float Rotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
mousecontrolX = Input.GetAxis("Mouse X") * mousesensitivity *Time.deltaTime;
mousecontrolY = Input.GetAxis("Mouse Y") * mousesensitivity * Time.deltaTime;
Rotation -= mousecontrolY;
Rotation = Mathf.Clamp(Rotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(Rotation, 0f, 0f);
player.Rotate(Vector3.up * mousecontrolX);
}
}
Theres the code i use for my camera.
Comment
Answer by sansuno68 · Dec 31, 2021 at 10:08 PM
Yeah thats pretty normal so make it like that.
Create A Child Object and place it where you want the cam to look at.
And Change in the Script everything that is saying player with the child object u created