Merge branch 'main' of https://scove-vault.duckdns.org/scove/HALLUCINATION
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using OnlyScove.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
@@ -24,13 +25,19 @@ namespace Invector.vCharacterController
|
||||
public KeyCode toggleWalk = KeyCode.CapsLock;
|
||||
|
||||
[Header("Movement Input")]
|
||||
public GenericInput horizontalInput = new GenericInput("Horizontal", "LeftAnalogHorizontal", "Horizontal");
|
||||
public GenericInput verticalInput = new GenericInput("Vertical", "LeftAnalogVertical", "Vertical");
|
||||
public GenericInput sprintInput = new GenericInput("LeftShift", "LeftStickClick", "LeftStickClick");
|
||||
public GenericInput crouchInput = new GenericInput("C", "Y", "Y");
|
||||
public GenericInput strafeInput = new GenericInput("Tab", "RightStickClick", "RightStickClick");
|
||||
public GenericInput jumpInput = new GenericInput("Space", "X", "X");
|
||||
public GenericInput rollInput = new GenericInput("Q", "B", "B");
|
||||
|
||||
|
||||
|
||||
// public GenericInput horizontalInput = new GenericInput("Horizontal", "LeftAnalogHorizontal", "Horizontal");
|
||||
// public GenericInput verticalInput = new GenericInput("Vertical", "LeftAnalogVertical", "Vertical");
|
||||
// public GenericInput sprintInput = new GenericInput("LeftShift", "LeftStickClick", "LeftStickClick");
|
||||
// public GenericInput crouchInput = new GenericInput("C", "Y", "Y");
|
||||
// public GenericInput strafeInput = new GenericInput("Tab", "RightStickClick", "RightStickClick");
|
||||
// public GenericInput jumpInput = new GenericInput("Space", "X", "X");
|
||||
// public GenericInput rollInput = new GenericInput("Q", "B", "B");
|
||||
|
||||
[Header("New Input System")]
|
||||
public OnlyScove.Scripts.InputReader inputReader;
|
||||
|
||||
protected bool _lockInput = false;
|
||||
[HideInInspector] public virtual bool lockInput { get { return _lockInput; } set { _lockInput = value; } }
|
||||
@@ -38,11 +45,11 @@ namespace Invector.vCharacterController
|
||||
[vEditorToolbar("Camera Settings")]
|
||||
public bool lockCameraInput;
|
||||
public bool invertCameraInputVertical, invertCameraInputHorizontal;
|
||||
[vEditorToolbar("Inputs")]
|
||||
// [vEditorToolbar("Inputs")]
|
||||
[Header("Camera Input")]
|
||||
public GenericInput rotateCameraXInput = new GenericInput("Mouse X", "RightAnalogHorizontal", "Mouse X");
|
||||
public GenericInput rotateCameraYInput = new GenericInput("Mouse Y", "RightAnalogVertical", "Mouse Y");
|
||||
public GenericInput cameraZoomInput = new GenericInput("Mouse ScrollWheel", "", "");
|
||||
// public GenericInput rotateCameraXInput = new GenericInput("Mouse X", "RightAnalogHorizontal", "Mouse X");
|
||||
// public GenericInput rotateCameraYInput = new GenericInput("Mouse Y", "RightAnalogVertical", "Mouse Y");
|
||||
// public GenericInput cameraZoomInput = new GenericInput("Mouse ScrollWheel", "", "");
|
||||
|
||||
[vEditorToolbar("Events")]
|
||||
public UnityEvent OnLockCamera;
|
||||
@@ -137,6 +144,33 @@ namespace Invector.vCharacterController
|
||||
ShowCursor(showCursorOnStart);
|
||||
LockCursor(unlockCursorOnStart);
|
||||
EnableOnAnimatorMove();
|
||||
if (inputReader != null)
|
||||
{
|
||||
// Nhảy (Jump)
|
||||
inputReader.OnJumpEvent += () =>
|
||||
{
|
||||
if (JumpConditions()) cc.Jump(true);
|
||||
};
|
||||
|
||||
// Lộn vòng (Roll / Dodge)
|
||||
inputReader.OnDodgeEvent += () =>
|
||||
{
|
||||
if (RollConditions()) cc.Roll();
|
||||
};
|
||||
|
||||
// Ngồi (Crouch)
|
||||
inputReader.OnCrouchEvent += () =>
|
||||
{
|
||||
cc.AutoCrouch();
|
||||
cc.Crouch();
|
||||
};
|
||||
|
||||
// Đổi góc nhìn hoặc Khóa mục tiêu (Strafe) - Tuỳ bạn map nút nào vào OnToggleViewEvent
|
||||
inputReader.OnToggleViewEvent += () =>
|
||||
{
|
||||
cc.Strafe();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IEnumerator CharacterInit()
|
||||
@@ -449,19 +483,26 @@ namespace Invector.vCharacterController
|
||||
|
||||
public virtual void MoveInput()
|
||||
{
|
||||
if (inputReader == null) return;
|
||||
if (!lockMoveInput)
|
||||
{
|
||||
// gets input
|
||||
var input = cc.input;
|
||||
input.x = horizontalInput.GetAxisRaw();
|
||||
input.z = verticalInput.GetAxisRaw();
|
||||
// input.x = horizontalInput.GetAxisRaw();
|
||||
// input.z = verticalInput.GetAxisRaw();
|
||||
// Input.GetAxisRaw("Horizontal");
|
||||
// Input.GetAxisRaw("Vertical");
|
||||
|
||||
input.x = inputReader.MoveInput.x;
|
||||
input.z = inputReader.MoveInput.y;
|
||||
cc.input = input;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(toggleWalk))
|
||||
{
|
||||
cc.alwaysWalkByDefault = !cc.alwaysWalkByDefault;
|
||||
}
|
||||
//if (Input.GetKeyDown(toggleWalk))
|
||||
//{
|
||||
//cc.alwaysWalkByDefault = !cc.alwaysWalkByDefault;
|
||||
//}
|
||||
Input.GetKeyDown(KeyCode.CapsLock);
|
||||
|
||||
cc.ControlKeepDirection();
|
||||
}
|
||||
@@ -489,28 +530,30 @@ namespace Invector.vCharacterController
|
||||
|
||||
public virtual void StrafeInput()
|
||||
{
|
||||
if (strafeInput.GetButtonDown())
|
||||
{
|
||||
cc.Strafe();
|
||||
}
|
||||
// if (strafeInput.GetButtonDown())
|
||||
// {
|
||||
// cc.Strafe();
|
||||
// }
|
||||
}
|
||||
|
||||
public virtual void SprintInput()
|
||||
{
|
||||
if (sprintInput.useInput)
|
||||
{
|
||||
cc.Sprint(cc.useContinuousSprint ? sprintInput.GetButtonDown() : sprintInput.GetButton());
|
||||
}
|
||||
// if (sprintInput.useInput)
|
||||
// {
|
||||
// cc.Sprint(cc.useContinuousSprint ? sprintInput.GetButtonDown() : sprintInput.GetButton());
|
||||
// }
|
||||
if (inputReader == null) return;
|
||||
cc.Sprint(inputReader.IsSprintHeld);
|
||||
}
|
||||
|
||||
public virtual void CrouchInput()
|
||||
{
|
||||
cc.AutoCrouch();
|
||||
|
||||
if (crouchInput.useInput && crouchInput.GetButtonDown())
|
||||
{
|
||||
cc.Crouch();
|
||||
}
|
||||
// if (crouchInput.useInput && crouchInput.GetButtonDown())
|
||||
// {
|
||||
// cc.Crouch();
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -527,10 +570,10 @@ namespace Invector.vCharacterController
|
||||
/// </summary>
|
||||
public virtual void JumpInput()
|
||||
{
|
||||
if (jumpInput.GetButtonDown() && JumpConditions())
|
||||
{
|
||||
cc.Jump(true);
|
||||
}
|
||||
// if (jumpInput.GetButtonDown() && JumpConditions())
|
||||
// {
|
||||
// cc.Jump(true);
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -547,10 +590,10 @@ namespace Invector.vCharacterController
|
||||
/// </summary>
|
||||
public virtual void RollInput()
|
||||
{
|
||||
if (rollInput.GetButtonDown() && RollConditions())
|
||||
{
|
||||
cc.Roll();
|
||||
}
|
||||
// if (rollInput.GetButtonDown() && RollConditions())
|
||||
// {
|
||||
// cc.Roll();
|
||||
// }
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -568,20 +611,19 @@ namespace Invector.vCharacterController
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!cameraMain || tpCamera == null || inputReader == null) return;
|
||||
|
||||
var Y = lockCameraInput ? 0f : rotateCameraYInput.GetAxis();
|
||||
var X = lockCameraInput ? 0f : rotateCameraXInput.GetAxis();
|
||||
if (invertCameraInputHorizontal)
|
||||
{
|
||||
X *= -1;
|
||||
}
|
||||
|
||||
if (invertCameraInputVertical)
|
||||
{
|
||||
Y *= -1;
|
||||
}
|
||||
|
||||
var zoom = cameraZoomInput.GetAxis();
|
||||
// var Y = lockCameraInput ? 0f : rotateCameraYInput.GetAxis();
|
||||
// var X = lockCameraInput ? 0f : rotateCameraXInput.GetAxis();
|
||||
|
||||
var Y = lockCameraInput ? 0f : inputReader.LookInput.y;
|
||||
var X = lockCameraInput ? 0f : inputReader.LookInput.x;
|
||||
|
||||
if (invertCameraInputHorizontal) X *= -1;
|
||||
if (invertCameraInputVertical) Y *= -1;
|
||||
|
||||
// var zoom = cameraZoomInput.GetAxis();
|
||||
var zoom = inputReader.ScrollInput.y;
|
||||
|
||||
tpCamera.RotateCamera(X, Y);
|
||||
if (!lockCameraInput)
|
||||
|
||||
Reference in New Issue
Block a user