Hello, I’m new to programing and I’m trying to script a very concrete type of camera.
I need a fixed camera in the z axis that rotates on his axis. That can be moved with WASD only in the X and Y.
With a limiter on the movement on X and Y.
Thanks to everyone that is willing to give any davice.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraRotateScript : MonoBehaviour
{
[Header ("Camera Settings")]
public float CameraRotation;
public float CameraSpeed;
private float x;
private float y;
public float sensitivity;
private Vector3 rotate;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
y = Input.GetAxis("Mouse X");
x = Input.GetAxis("Mouse Y");
rotate = new Vector3(x, y * sensitivity, 0);
transform.eulerAngles = transform.eulerAngles - rotate;
}