add empty project with character controller

Added empty project with camera controller and basic player controller
This commit is contained in:
DerTyp187
2021-09-21 17:42:31 +02:00
parent 03d4d69d93
commit 61294cb761
38 changed files with 3401 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
[SerializeField] private float mouseSensitivityX = 800f;
[SerializeField] private float mouseSensitivityY = 700f;
[SerializeField] private Transform playerBody; //Transform of "First Person Player" Object
private float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;//Lock Cursor in the center
}
void Update()
{
//Input.GetAxis is based on the Unity Input settings (edit -> Project Settings -> Input Manager)
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivityX * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivityY * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f); //Kopf darf sich nicht <20>berschlagen
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);//Y Achse rotieren; Quaternion ist f<>r rotation
playerBody.Rotate(Vector3.up * mouseX); //X Achse Rotieren
}
}