Changed input manager to new system, added jump timer to "fix" jump mechanic (Double jumps, no jumps, etc.)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user