Question by
wetcoco · Jul 17, 2021 at 02:01 PM ·
camerainput.getaxis
Camera movement system not working
So I've been making a bad copy of minecraft (I won't publish it of course) and the very first problem I'm encountering since I've started is my camera not wanting to move (so far I've only done that in the player movement system)
Anyone can tell me why and how to fix it?
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private Transform camera;
private float horizontal;
private float vertical;
private float mouseHorizontal;
private float mouseVertical;
private Vector3 velocity;
private void Start()
{
camera = GameObject.Find("PlayerCamera").transform;
}
private void Update()
{
GetPlayerInputs();
transform.Rotate(Vector3.up * mouseHorizontal);
camera.Rotate(Vector3.right * -mouseVertical);
}
private void GetPlayerInputs()
{
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
mouseHorizontal = Input.GetAxis("Mouse X");
mouseVertical = Input.GetAxis("Mouse Y");
}
}
Comment
Your answer
Follow this Question
Related Questions
Camer do not render correctly! 0 Answers
How to make a FreeLook camera 1 Answer
How to make the camera NOT rotate with it's father 1 Answer
Multiple Monitor Support 0 Answers
(C#) Switching between two cameras - one not appearing (noob) 0 Answers