Physics Part 3

Download

Unity Cheat Sheet: #42

Applying Forces to Objects

  • AddForce with ForceMode.Force: For continuous pushing
  • AddForce with ForceMode.Impulse: For instant impacts like jumps
  • AddTorque: For spinning and rotating objects
  • AddExplosionForce: For blast effects with radius and falloff

Creating Bouncy Surfaces

  • Create PhysicMaterial and set bounciness (can exceed 1 for extra bounce)
  • Configure friction behavior with frictionCombine
  • Set bounce behavior with bounceCombine
  • Apply to colliders via material property

Detecting Objects with Raycasts

  • Cast rays to detect objects in a straight line
  • Access hit object through hit.collider.gameObject
  • Get hit distance and precise world position
  • Create custom rays for more control

Finding Objects in an Area

  • OverlapSphere for radius-based detection
  • Process found colliders with foreach loops
  • OverlapBox for rectangular detection areas
  • Filter by layers using LayerMask.GetMask

Motion Constraints & Smoothing

  • Freeze all movement with RigidbodyConstraints.FreezeAll
  • Selectively lock axes by combining constraints
  • Set rigidbody.freezeRotation = true to lock all rotation
  • Enable interpolation for visually smoother movement between frames

Show More