Changed input manager to new system, added jump timer to "fix" jump mechanic (Double jumps, no jumps, etc.)

This commit is contained in:
finnchen123
2026-02-18 15:44:25 +01:00
parent 6884c7e031
commit 053b99f62c
6 changed files with 497 additions and 123 deletions

View File

@@ -29,9 +29,10 @@ namespace Assets.Scripts.Player
bool finishedGame = false;
PlayerObject player;
DateTime now;
int jumpFrameCounter;
public bool isArmed;
bool canJump;
public float secondsSinceJump;
public int secondsUntilJump = 5;
private void OnEnable()
{
@@ -65,8 +66,8 @@ namespace Assets.Scripts.Player
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
}
isArmed = true;
jumpFrameCounter = 0;
canJump = false;
canJump = true;
secondsSinceJump = secondsUntilJump;
}
// Update is called once per frame
@@ -88,6 +89,18 @@ namespace Assets.Scripts.Player
SteamWorksHandler.getStandardAchievement("DeathAchievement");
uihandler.showDeathScreen();
}
if (!canJump)
{
secondsSinceJump += Time.deltaTime;
if (secondsSinceJump >= secondsUntilJump)
{
canJump = true;
}
}
else
{
secondsSinceJump = secondsUntilJump;
}
}
private void regeneratePlayer()
@@ -167,14 +180,6 @@ namespace Assets.Scripts.Player
public void move(Vector3 input, bool isSprinting)
{
if(gameObject.GetComponent<Rigidbody>().linearVelocity.y <= 0.1f && gameObject.GetComponent<Rigidbody>().linearVelocity.y >= -0.1f){
jumpFrameCounter++;
}
if(jumpFrameCounter >= 10){
canJump = true;
jumpFrameCounter = 0;
}
if (input.y != 0)
{
if (canJump)
@@ -182,6 +187,7 @@ namespace Assets.Scripts.Player
gameObject.GetComponent<Rigidbody>().linearVelocity = new Vector3(0, 5, 0);
audioHandler.playJump();
canJump = false;
secondsSinceJump = 0;
}
}
Vector3 movement = new Vector3(input.x, 0, input.z);