work on switch to new input system

This commit is contained in:
2025-11-19 20:24:23 -08:00
parent 4de639cdd7
commit 80be13ce72
5 changed files with 236 additions and 17 deletions

View File

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

View File

@@ -41,6 +41,24 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Look",
"type": "Value",
"id": "7fba5b60-8d24-49b6-8308-c70e6a63c456",
"expectedControlType": "Vector2",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Run",
"type": "Button",
"id": "5a6630db-ebaf-4fde-9e52-f04136a77988",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@@ -175,6 +193,50 @@
"action": "Pause",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "74ebb1b9-ab13-42d0-956f-019b25fb646b",
"path": "<Gamepad>/rightStick",
"interactions": "",
"processors": "",
"groups": "",
"action": "Look",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "2c4bb4fd-6d38-4424-a2de-e798aeef5dd7",
"path": "<Mouse>/delta",
"interactions": "",
"processors": "",
"groups": "",
"action": "Look",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "ac8271b8-5a0c-498a-b97b-57546775b0b9",
"path": "<Gamepad>/leftStickPress",
"interactions": "",
"processors": "",
"groups": "",
"action": "Run",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "34fcda37-2f7d-40e9-a510-fff20ecd0672",
"path": "<Keyboard>/leftShift",
"interactions": "",
"processors": "",
"groups": "",
"action": "Run",
"isComposite": false,
"isPartOfComposite": false
}
]
}

Binary file not shown.

View File

@@ -5,10 +5,10 @@ public class PlayerCam : MonoBehaviour
{
float sens;
public Transform orientation;
public Transform player;
float xRotation;
float yRotation;
float mouseX;
float mouseY;
public Vector2 lookInput;
public Transform wagonRot;
private Quaternion previousSourceRotation;
@@ -51,19 +51,19 @@ public class PlayerCam : MonoBehaviour
sens = Sensitivity.value;
if (canLook)
{
mouseX = Input.GetAxis("Mouse X") * sens;
mouseY = Input.GetAxis("Mouse Y") * sens;
yRotation += lookInput.x * sens * Time.deltaTime;
xRotation -= lookInput.y * sens * Time.deltaTime;
}
yRotation += mouseX;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -87f, 87f);
transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);
player.rotation = Quaternion.Euler(0, yRotation, 0);
}
}

View File

@@ -30,7 +30,6 @@ public class PlayerMovement : MonoBehaviour
public InputAction pauseGameButton;
public Transform orientation;
public Transform cameraor;
@@ -47,6 +46,7 @@ public class PlayerMovement : MonoBehaviour
public float timeSinceLastSwing;
public bool holdSwing;
public float holdSwingTimer;
public bool swingBeingHeld;
public float dashDistanceTimer, dashDistance, dashDuration;
public Collider myCollider;
@@ -64,7 +64,7 @@ public class PlayerMovement : MonoBehaviour
float energyObjTimer;
public GameObject energyFill;
public bool jumped;
@@ -85,12 +85,65 @@ public class PlayerMovement : MonoBehaviour
void Update()
{
MyInput();
if (pauseGameButton.WasPerformedThisFrame())
timeSinceLastSwing += Time.deltaTime;
if (timeSinceLastSwing > .5f)
lastSwing = 0;
holdSwingTimer += Time.deltaTime;
if (holdSwing && holdSwingTimer > .15f)
holdSwing = false;
else if (holdSwing && GameObject.FindGameObjectsWithTag("Sword").Length < 1)
{
holdSwing = false;
if (energy > 7)
SwingSword();
}
if (!holdSwing)
holdSwingTimer = 0;
if (swung)
{
swungTimer += Time.deltaTime;
}
if (swungTimer > 1f)
swung = false;
if (!swung)
{
swungTimer = 0;
energy += 70 * Time.deltaTime;
}
if (energy < 0)
energy = 0;
if (energy > 100)
energy = 100;
energySlider.value = energy;
healthUI.sizeDelta = new Vector2((Mathf.Ceil(HP) - 1) + (9 * HP), healthUI.sizeDelta.y);
//MyInput();
if (swingBeingHeld)
{
swung = true;
swungTimer = 0;
timeSinceLastSwing = 0;
energy -= 20 * Time.deltaTime;
dashDistanceTimer += Time.deltaTime;
if (dashDistanceTimer > 1)
energyFill.GetComponent<Image>().color = Color.deepPink;
if (energy <= 0)
{
if (dashDistanceTimer > 1)
{
dashDistance = Mathf.Floor(dashDistanceTimer * 8);
dashDuration = 15;
}
dashDistanceTimer = 0;
}
}
if (energy == 100)
{
@@ -106,9 +159,46 @@ public class PlayerMovement : MonoBehaviour
energyObjTimer = 0;
energyObj.SetActive(true);
}
}
void FixedUpdate()
{
if (dashDuration > 0)
{
SwordDash();
dashDuration--;
}
if (dashDuration == 1)
{
//rb.linearVelocity = Vector3.zero;
dashDuration--;
}
if (canWalk /*&& !running*/)
{
Vector3 move = new Vector3(moveInput.x * speed, 0, moveInput.y * speed);
Vector3 move2 = transform.TransformDirection(move);
controller.Move(move2 * Time.deltaTime);
}
//else if (canWalk && running)
//{
// Vector3 move = new Vector3(moveInput.x * speed, 0, moveInput.y * runSpeed);
// Vector3 move2 = transform.TransformDirection(move);
// controller.Move(move2 * Time.deltaTime);
//}
controller.Move(velocity * Time.deltaTime);
if (!controller.isGrounded)
{
velocity.y += gravity * Time.deltaTime;
}
else if (controller.isGrounded)
{
//velocity.y = 0;
}
}
public void PauseGame(InputAction.CallbackContext context)
@@ -131,6 +221,72 @@ public class PlayerMovement : MonoBehaviour
Cursor.visible = false;
}
}
public void OnMove(InputAction.CallbackContext context)
{
moveInput = context.ReadValue<Vector2>();
}
public void OnRun(InputAction.CallbackContext context)
{
if (context.performed && moveAnimationInputY == 1 && !running)
{
running = true;
}
else if (context.performed && moveAnimationInputY == 2 && running)
{
running = false;
moveAnimationInputY = 1;
}
if (context.canceled)
{
//running = false;
}
}
public void OnLook(InputAction.CallbackContext context)
{
playerCam.lookInput = context.ReadValue<Vector2>();
}
public void OnAttack(InputAction.CallbackContext context)
{
if (context.performed && inventorySlot == 1)
{
swingBeingHeld = true;
if (GameObject.FindGameObjectsWithTag("Sword").Length < 1)
{
if (energy > 7)
SwingSword();
}
else
{
swung = true;
swungTimer = 0;
holdSwingTimer = 0;
holdSwing = true;
}
}
if (context.canceled && inventorySlot == 1)
{
swingBeingHeld = false;
energyFill.GetComponent<Image>().color = Color.darkRed;
if (dashDistanceTimer > 1)
{
dashDistance = Mathf.Floor(dashDistanceTimer * 8);
dashDuration = 15;
}
dashDistanceTimer = 0;
}
}
public void OnJump(InputAction.CallbackContext context)
{
if (context.performed && controller.isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * -1f * gravity);
jumped = true;
}
if (context.canceled && !controller.isGrounded)
{
jumped = false;
}
}
private void MyInput()
{
@@ -294,7 +450,7 @@ public class PlayerMovement : MonoBehaviour
private void SwordDash()
{
myCollider.excludeLayers = excludeEnemy;
Debug.Log($"distance:{dashDistance}");
//rb.AddForce(Camera.main.transform.forward * dashDistance, ForceMode.Impulse);
swung = true;
swungTimer = 0;