feat: scene built, basic function completed
This commit is contained in:
24
Assets/scripts/CameraControllerY.cs
Normal file
24
Assets/scripts/CameraControllerY.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraControllerY : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float mouseSpeed = 500f;
|
||||
|
||||
private float pitch = 0f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float mouseY = Input.GetAxis("Mouse Y");
|
||||
|
||||
pitch -= mouseY * mouseSpeed * Time.deltaTime;
|
||||
|
||||
pitch = Mathf.Clamp(pitch, -90f, 30f);
|
||||
|
||||
transform.localRotation = Quaternion.Euler(pitch, 0f, 0f);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user