How do I stop the camera rotating on the Z axis (tilting left and right),How do I stop the camera from tilting when I turn?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
transform.Translate(Input.GetAxis("Horizontal")*Time.deltaTime,0f,0f);
transform.Translate(0f, 0f, Input.GetAxis("Vertical") * Time.deltaTime);
transform.Rotate(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0);
}
}
Also on a slightly unrelated note, anyone know how to get visual studio to autocomplete with c# results? Using youtube tutorials but I would love to see the functions I could try.,When I look left and right the camera turns on what I think is the Z axis, it tilts right and left like im tilting my head left and right, but I cant figure out how to stop it.
Heres my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
transform.Translate(Input.GetAxis("Horizontal")*Time.deltaTime,0f,0f);
transform.Translate(0f, 0f, Input.GetAxis("Vertical") * Time.deltaTime);
transform.Rotate(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0);
}
}
Oh and also, anyone know how to get visual studio to add c# functions to the autocomplete thing? kinda going off tutorials on youtube, would love to see what I can try
Thank you to those who help
Just adding: Due to a bug, when I signed in (after I typed the post the first time) all the fields were blank, so I thought I had to retype it, didnt know all the things were still there
Your answer
Follow this Question
Related Questions
Rotate Unity3D FirstPersonCamera with values from Arduino in form of -127 to 127 (degrees) … 0 Answers
Camera Quaternion.RotateTowards without rolling/banking 1 Answer
Switch between touchscreen and Google VR to control the Unity camera 1 Answer
How do I make the camera look at three possible perspectives? 0 Answers
Camera rotation with mouse cursor 0 Answers