Added Framecap in Prefab

This commit is contained in:
DominikB
2023-06-25 12:04:22 +02:00
parent a3cfd71e42
commit d6b648ead0
4 changed files with 30 additions and 11 deletions

View File

@@ -13,6 +13,7 @@ public class FallingDetection : MonoBehaviour
public AudioClip sprungSound; // The sound clip to be played
public bool isJumping = false;
public int counterFall = 0;
public bool didLandDuringJump = false;
private void Start()
@@ -28,7 +29,9 @@ public class FallingDetection : MonoBehaviour
Vector3 velocity = playerRigidbody.velocity;
//Wenn nicht auf boden und geschwindigkeits offset pos
if (!charController.grounded && velocity.y > 0.1f && !isJumping){
audioSource.PlayOneShot(sprungSound);
didLandDuringJump = charController.grounded;
if(!didLandDuringJump){
audioSource.PlayOneShot(sprungSound);}
isJumping = true;
}
if(charController.grounded){
@@ -41,6 +44,7 @@ public class FallingDetection : MonoBehaviour
isFalling = true;
animator.SetBool("IsFalling", true);
counter = 0;
if(counterFall++>35){
wasFallingbefore = true;}
}
@@ -49,10 +53,14 @@ public class FallingDetection : MonoBehaviour
counter = 0;
counterFall=0;
animator.SetBool("IsFalling", false);
didLandDuringJump = false;
if(wasFallingbefore){
wasFallingbefore = false;
audioSource.PlayOneShot(landeSound);
}
}
if (charController.grounded && (Mathf.Abs(velocity.y)<0.01f)){
didLandDuringJump = false;
}
}
}