Added Framecap in Prefab
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user