work on switch to new input system

This commit is contained in:
2025-11-19 15:29:45 -08:00
parent ef170ca6c6
commit 4de639cdd7
7 changed files with 245 additions and 1281 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -20,7 +20,8 @@ Material:
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3

Binary file not shown.

View File

@@ -0,0 +1,183 @@
{
"version": 1,
"name": "PlayerControls",
"maps": [
{
"name": "Walking",
"id": "1e7ba32d-4065-405c-9b0c-fe0b09743eb3",
"actions": [
{
"name": "Walk",
"type": "Value",
"id": "3a2bd67d-4457-4f11-b1fc-c86379804bb1",
"expectedControlType": "Vector2",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Attack",
"type": "Button",
"id": "f8dcb10a-f2c6-43c1-9aaf-f11c20421cd1",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Jump",
"type": "Button",
"id": "cec6d443-6127-4956-b159-38ca8562aa98",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Pause",
"type": "Button",
"id": "5c32bd40-94aa-43cd-8964-7cc6e6fe0841",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "",
"id": "2a3f4ee7-cbd7-4664-984f-750f150f8d63",
"path": "<Gamepad>/leftStick",
"interactions": "",
"processors": "",
"groups": "",
"action": "Walk",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "2D Vector",
"id": "f127319e-6995-4349-bc8a-8d71b1b1c9f9",
"path": "2DVector",
"interactions": "",
"processors": "",
"groups": "",
"action": "Walk",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "up",
"id": "a90b9406-f8c9-41a6-acf9-073de4d92e91",
"path": "<Keyboard>/w",
"interactions": "",
"processors": "",
"groups": "",
"action": "Walk",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "1bebfb21-bb71-4512-9291-6f0500a3d82b",
"path": "<Keyboard>/s",
"interactions": "",
"processors": "",
"groups": "",
"action": "Walk",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "07a58494-4f87-4c68-a0ac-f51461fb40a5",
"path": "<Keyboard>/a",
"interactions": "",
"processors": "",
"groups": "",
"action": "Walk",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "cc51b20a-9c2b-464f-9f63-f83e8bcc34f0",
"path": "<Keyboard>/d",
"interactions": "",
"processors": "",
"groups": "",
"action": "Walk",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "2b5b52b2-8b25-451e-a6b7-8cf81f0d050f",
"path": "<Gamepad>/rightTrigger",
"interactions": "",
"processors": "",
"groups": "",
"action": "Attack",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "fe8bd868-92c9-4b6e-9bc5-14344cb2b727",
"path": "<Mouse>/leftButton",
"interactions": "",
"processors": "",
"groups": "",
"action": "Attack",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "6471cb05-e4f9-4cdc-809c-2629fdee010a",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "20ba707d-cf88-4683-9ad7-2a705b1129c6",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "4e0041d6-e3b6-4e5e-88db-fa3dd30b2c4c",
"path": "<Gamepad>/start",
"interactions": "",
"processors": "",
"groups": "",
"action": "Pause",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "abbc102c-00c8-4291-bfa3-39ed3704b6e8",
"path": "<Keyboard>/escape",
"interactions": "",
"processors": "",
"groups": "",
"action": "Pause",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": []
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 052faaac586de48259a63d0c4782560b
guid: 96337c2766116244abd3c3ed43585709
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}

Binary file not shown.

View File

@@ -6,22 +6,30 @@ using UnityEngine.Rendering.PostProcessing;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed;
public float moveSpeedMultiplier;
public CharacterController controller;
private Vector2 moveInput;
private float moveAnimationInputX;
private float moveAnimationInputY;
private Vector3 velocity;
public float speed;
public float runSpeed;
public float gravity;
public float jumpHeight;
public PlayerCam playerCam;
public bool canWalk;
float walkResetTimer;
bool walkResetTimerGo;
bool running;
public InputAction pauseGameButton;
public LayerMask whatIsGround;
public bool grounded;
public Collider groundedCollider;
public float airMultiplier;
public bool airCollided;
public bool groundCollided;
public float maxSlopeAngle;
private RaycastHit slopeHit;
private bool exitingSlope;
public Transform orientation;
public Transform cameraor;
@@ -56,36 +64,32 @@ public class PlayerMovement : MonoBehaviour
float energyObjTimer;
public GameObject energyFill;
Vector3 moveDirection;
Rigidbody rb;
public PhysicsMaterial walkingPhysics;
public PhysicsMaterial standingPhysics;
public PhysicsMaterial airColliding;
public GameObject particle1;
public GameObject particle2;
public VolumeProfile volumeProfile;
public RectTransform healthUI;
bool jumped;
bool jumping;
public GameObject uiController;
void Start()
{
cinemachineCam = GameObject.Find("CinemachineCamera");
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
canWalk = true;
}
void Update()
{
MyInput();
SpeedControl();
if (pauseGameButton.WasPerformedThisFrame())
{
}
if (energy == 100)
@@ -105,111 +109,42 @@ public class PlayerMovement : MonoBehaviour
}
void FixedUpdate()
{
MovePlayer();
}
public void PauseGame(InputAction.CallbackContext context)
{
if (Time.timeScale == 1 && context.performed)
{
uiController.GetComponent<PauseMenuControls>().mainCanvas.enabled = false;
uiController.GetComponent<PauseMenuControls>().pauseCanvas.enabled = true;
Time.timeScale = 0;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else if (context.performed)
{
uiController.GetComponent<PauseMenuControls>().mainCanvas.enabled = true;
uiController.GetComponent<PauseMenuControls>().pauseCanvas.enabled = false;
uiController.GetComponent<PauseMenuControls>().settingsCanvas.enabled = false;
Time.timeScale = 1;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
private void MyInput()
{
if (Input.GetKeyDown(KeyCode.Alpha7))
{
HP -= 1;
}
if (Input.GetKeyDown(KeyCode.Alpha8))
{
HP -= .5f;
}
if (Input.GetKey(KeyCode.Alpha9))
{
HP -= Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Alpha6))
{
HP = 10;
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
inventorySlot = 1;
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
inventorySlot = 2;
}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
inventorySlot = 3;
}
if (inventorySlot > 3)
inventorySlot = 3;
if (inventorySlot < 1)
inventorySlot = 1;
if (Input.GetKeyDown(KeyCode.Escape))
{
if (Time.timeScale == 1)
{
uiController.GetComponent<PauseMenuControls>().mainCanvas.enabled = false;
uiController.GetComponent<PauseMenuControls>().pauseCanvas.enabled = true;
Time.timeScale = 0;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
uiController.GetComponent<PauseMenuControls>().mainCanvas.enabled = true;
uiController.GetComponent<PauseMenuControls>().pauseCanvas.enabled = false;
uiController.GetComponent<PauseMenuControls>().settingsCanvas.enabled = false;
Time.timeScale = 1;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
horizontalInput = Input.GetAxisRaw("Horizontal");
verticalInput = Input.GetAxisRaw("Vertical");
if (horizontalInput == 0 && verticalInput == 0 && grounded && !Input.GetKeyDown(KeyCode.Space))
{
rb.linearDamping = 7;
GetComponent<CapsuleCollider>().material = standingPhysics;
}
else if (horizontalInput != 0 || verticalInput != 0 || !grounded || Input.GetKeyDown(KeyCode.Space))
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = walkingPhysics;
}
if (Input.GetKeyDown(KeyCode.Space) && grounded)
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = walkingPhysics;
jumped = true;
jumping = true;
}
if (jumped)
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = walkingPhysics;
if (jumping)
{
rb.AddForce(Vector3.up * 6, ForceMode.Impulse);
jumping = false;
}
}
if (airCollided && !grounded)
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = airColliding;
//rb.AddForce(Vector3.down * 1, ForceMode.Force);
Debug.Log("ng, hs");
}
@@ -313,10 +248,6 @@ public class PlayerMovement : MonoBehaviour
}
}
}
private void LateUpdate()
{
}
private void SwingSword()
{
@@ -345,22 +276,8 @@ public class PlayerMovement : MonoBehaviour
private void MovePlayer()
{
moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
if (grounded)
rb.AddForce(moveDirection.normalized * moveSpeed * moveSpeedMultiplier * 3, ForceMode.Force);
else if (!grounded)
rb.AddForce(moveDirection.normalized * moveSpeed * moveSpeedMultiplier * airMultiplier, ForceMode.Force);
if (rb.linearVelocity.y < -1)
{
rb.AddForce(transform.up * -5, ForceMode.Force);
}
if (dashDuration > 0)
{
SwordDash();
@@ -369,7 +286,7 @@ public class PlayerMovement : MonoBehaviour
}
if (dashDuration == 1)
{
rb.linearVelocity = Vector3.zero;
//rb.linearVelocity = Vector3.zero;
dashDuration--;
}
@@ -378,90 +295,11 @@ public class PlayerMovement : MonoBehaviour
{
myCollider.excludeLayers = excludeEnemy;
rb.AddForce(Camera.main.transform.forward * dashDistance, ForceMode.Impulse);
//rb.AddForce(Camera.main.transform.forward * dashDistance, ForceMode.Impulse);
swung = true;
swungTimer = 0;
timeSinceLastSwing = 0;
}
private void SpeedControl()
{
{
Vector3 flatVel = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z);
if (flatVel.magnitude > moveSpeed)
{
Vector3 limitedVel = flatVel.normalized * moveSpeed;
rb.linearVelocity = new Vector3(limitedVel.x, rb.linearVelocity.y, limitedVel.z);
}
}
}
private bool OnSlope()
{
if (Physics.Raycast(transform.position, Vector3.down, out slopeHit, 2 * 0.5f + 0.3f))
{
float angle = Vector3.Angle(Vector3.up, slopeHit.normal);
return angle < maxSlopeAngle && angle != 0;
}
return false;
}
private Vector3 GetSlopeDirection()
{
return Vector3.ProjectOnPlane(moveDirection, slopeHit.normal).normalized;
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Enemy")
{
HP--;
}
if (!other.isTrigger/* && other.gameObject.tag == "Ground"*/)
{
grounded = true;
if (jumped)
jumped = false;
}
}
private void OnTriggerStay(Collider other)
{
if (!other.isTrigger/* && other.gameObject.tag == "Ground"*/)
{
grounded = true;
}
}
private void OnTriggerExit(Collider other)
{
if (!other.isTrigger/* && other.gameObject.tag == "Ground"*/)
{
grounded = false;
}
}
private void OnCollisionEnter(Collision collision)
{
if (!grounded)
{
}
}
private void OnCollisionStay(Collision collision)
{
if (!grounded)
{
airCollided = true;
}
}
private void OnCollisionExit(Collision collision)
{
if (!grounded)
{
airCollided = false;
}
}
}