Я пытаюсь сделать OG Doom, подобной игре, и я реализовал, что вы можете осмотреть вокруг, но я пытался добавить ее, чтобы посмотреть вверх и вниз, но это просто пойдет на полпути -точку/горизонт, а затем застрял. Он не будет превышать -90 на оси x. < /P>
using System.Net.Http.Headers;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public Rigidbody2D theRB;
public float moveSpeed =5f;
private Vector2 moveInput;
private Vector2 mouseInput;
public float mouseSensitivity = 2f;
public Transform viewCam;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
// player movement
moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
Vector3 moveHorizontal = transform.up * moveInput.y;
Vector3 moveVertical = transform.right * moveInput.x;
theRB.velocity = (moveHorizontal + moveVertical) * moveSpeed;
//player view control
mouseInput = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")) * mouseSensitivity;
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z - mouseInput.x);
viewCam.localRotation = Quaternion.Euler(viewCam.localRotation.eulerAngles - new Vector3(mouseInput.y, 0f, 0f));
}
}
< /code>
Это код, который я пытаюсь использовать, чтобы заставить его работать, но он не работает. Я пытался изменить другие значения, но это становится дурацким. Я просто хочу знать, есть ли способ заставить его посмотреть над горизонтом
Подробнее здесь: https://stackoverflow.com/questions/794 ... in-unity2d