72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using KinematicCharacterController;
|
|
using KinematicCharacterController.Examples;
|
|
using System.Linq;
|
|
|
|
namespace KinematicCharacterController.Walkthrough.NoClipState
|
|
{
|
|
public class MyPlayer : MonoBehaviour
|
|
{
|
|
public ExampleCharacterCamera OrbitCamera;
|
|
public Transform CameraFollowPoint;
|
|
public MyCharacterController Character;
|
|
|
|
private const string MouseXInput = "Mouse X";
|
|
private const string MouseYInput = "Mouse Y";
|
|
private const string MouseScrollInput = "Mouse ScrollWheel";
|
|
private const string HorizontalInput = "Horizontal";
|
|
private const string VerticalInput = "Vertical";
|
|
|
|
private void Start()
|
|
{
|
|
OrbitCamera.SetFollowTransform(CameraFollowPoint);
|
|
OrbitCamera.IgnoredColliders.Clear();
|
|
OrbitCamera.IgnoredColliders.AddRange(Character.GetComponentsInChildren<Collider>());
|
|
playerCharacterInputs.NoClipDown = true;
|
|
}
|
|
PlayerCharacterInputs playerCharacterInputs = new PlayerCharacterInputs();
|
|
private void Update()
|
|
{
|
|
Cursor.visible = true;
|
|
|
|
HandleCharacterInput();
|
|
}
|
|
//private int maxView = 80;
|
|
//private int minView = 10;
|
|
//private float slideSpeed = 20;
|
|
private void LateUpdate()
|
|
{
|
|
|
|
HandleCameraInput();
|
|
}
|
|
//private float _zoomSpeed = 1.6f;
|
|
//public float _ZoomSpeed { get => _zoomSpeed ; }
|
|
//private float _minZoom = 5.0f;
|
|
//private float _maxZoom = 100f;
|
|
private void HandleCameraInput()
|
|
{
|
|
|
|
float mouseLookAxisUp = 0;
|
|
float mouseLookAxisRight = 0;
|
|
//if (CG.UTility.PopUpMng._TriAble)
|
|
//{
|
|
mouseLookAxisUp = Input.GetAxis(MouseYInput);
|
|
mouseLookAxisRight = Input.GetAxis(MouseXInput);
|
|
//}
|
|
|
|
}
|
|
|
|
private void HandleCharacterInput()
|
|
{
|
|
PlayerCharacterInputs characterInputs = new PlayerCharacterInputs();
|
|
characterInputs.MoveAxisForward = Input.GetAxisRaw(VerticalInput);
|
|
characterInputs.MoveAxisRight = Input.GetAxisRaw(HorizontalInput);
|
|
characterInputs.JumpHeld = Input.GetKey(KeyCode.Q);
|
|
characterInputs.CrouchHeld = Input.GetKey(KeyCode.E);
|
|
characterInputs.CameraRotation = OrbitCamera.Transform.rotation;
|
|
Character.SetInputs(ref characterInputs);
|
|
}
|
|
}
|
|
} |