update
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace StarterAssets
|
||||
{
|
||||
public class StarterAssetsInputs : MonoBehaviour
|
||||
{
|
||||
[Header("Character Input Values")]
|
||||
public Vector2 move;
|
||||
public Vector2 look;
|
||||
public bool jump;
|
||||
public bool sprint;
|
||||
public bool crouch;
|
||||
public bool crawl;
|
||||
|
||||
[Header("Movement Settings")]
|
||||
public bool analogMovement;
|
||||
|
||||
[Header("Mouse Cursor Settings")]
|
||||
public bool cursorLocked = true;
|
||||
public bool cursorInputForLook = true;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
public void OnMove(InputValue value)
|
||||
{
|
||||
MoveInput(value.Get<Vector2>());
|
||||
}
|
||||
|
||||
public void OnLook(InputValue value)
|
||||
{
|
||||
if(cursorInputForLook)
|
||||
{
|
||||
LookInput(value.Get<Vector2>());
|
||||
}
|
||||
}
|
||||
|
||||
public void OnJump(InputValue value)
|
||||
{
|
||||
JumpInput(value.isPressed);
|
||||
}
|
||||
|
||||
public void OnSprint(InputValue value)
|
||||
{
|
||||
SprintInput(value.isPressed);
|
||||
}
|
||||
|
||||
public void OnCrouch(InputValue value)
|
||||
{
|
||||
crouch = value.isPressed;
|
||||
}
|
||||
|
||||
public void OnCrawl(InputValue value)
|
||||
{
|
||||
crawl = value.isPressed;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
public void MoveInput(Vector2 newMoveDirection)
|
||||
{
|
||||
move = newMoveDirection;
|
||||
}
|
||||
|
||||
public void LookInput(Vector2 newLookDirection)
|
||||
{
|
||||
look = newLookDirection;
|
||||
}
|
||||
|
||||
public void JumpInput(bool newJumpState)
|
||||
{
|
||||
jump = newJumpState;
|
||||
}
|
||||
|
||||
public void SprintInput(bool newSprintState)
|
||||
{
|
||||
sprint = newSprintState;
|
||||
}
|
||||
|
||||
private void OnApplicationFocus(bool hasFocus)
|
||||
{
|
||||
SetCursorState(cursorLocked);
|
||||
}
|
||||
|
||||
private void SetCursorState(bool newState)
|
||||
{
|
||||
Cursor.lockState = newState ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e087ecce43ebbff45a1b360637807d93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 196525
|
||||
packageName: Starter Assets - FirstPerson | Updates in new CharacterController
|
||||
package
|
||||
packageVersion: 1.3
|
||||
assetPath: Assets/StarterAssets/InputSystem/StarterAssetsInputs.cs
|
||||
uploadId: 691166
|
||||
Reference in New Issue
Block a user