private void CheckGroundCollision() { //Get the 10 first contacts of the box collider ContactPoint2D[] contacts = new ContactPoint2D[10]; int count = boxColl.GetContacts(contacts); //If we find any horizontal surfaces, we are on the ground onGround = false; for (int i = 0; i < count; i++) { //If the angle between the normal and up is less than 5, we are on the ground if (Vector2.Angle(contacts[i].normal, Vector2.up) < 5.0f) { //Sound effects audioManager.Play("LandingSound"); //Debug.Log("PrevFrameSpeed: " + previousFrameYSpeed); //Camera shake if (Mathf.Abs(previousFrameYSpeed) > 50) { float speedFraction = (Mathf.Abs(previousFrameYSpeed) - 50) / 150; float trauma = Mathf.Lerp(0, 1, speedFraction); cam.AddTrauma(trauma); //Debug.Log("Trauma: " + trauma + ", Speed fraction: " + speedFraction); } //Coyote time setup coyoteTimeActive = true; //Ground collision physics onGround = true; rb.velocity = new Vector2(rb.velocity.x, 0); } } }