Unity Physics Samples

January 24, 2025 ยท View on GitHub

For more Phyiscs and DOTS starter material, see the main page of this repo.

Controls

In the Game window:

  • Mouse spring : Click and drag with left mouse
  • Camera rotate : Click and drag with right mouse
  • Camera move : W,A,S,D keys

Debug Display

A lot of the demos display extra information as debug display gizmos in the Editor, for example the Query demos (ray cast, distance cast, etc). This display for these gizmos is in the Scene not the Game window. So keep an eye on both if in doubt:

Scene viewGame view
Game windowGame window

Scene List

CategorySceneDescriptionLevel
Hello WorldHello World.unityIntroductory scene for rigid body setupIntroductoryDemo image
Hello WorldSphereAndBoxColliders.unityBasic collidersIntroductoryDemo image
Hello WorldGravityWell.unityIntroductory sceneIntroductoryDemo image
Setup2a1. Collider Parade - Basic.unityDemo showing various shapes for collision detectionIntroductoryDemo image
Setup2a2. Collider Parade - AdvancedDemo showing various shapes for more advanced collision detectionIntroductoryDemo image
Setup2b1. Motion Properties - Mass.unityDemo showing how to explicitly set mass properties using custom (yellow) and built-in (grey) authoring componentsIntroductoryDemo image
Setup2b2. Motion Properties - Velocity.unitySetting initial linear and angular velocitiesIntroductoryDemo Image
Setup2b3. Motion Properties - Damping.unityDemo showing the effect of linear and angular dampingIntroductoryDemo Image
Setup2b4. Motion Properties - Gravity Factor.unityDemo showing the effect of per body gravity multipliersIntroductoryDemo Image
Setup2b5. Motion Properties - Center of Mass.unityDemo showing the effect of overriding center of massIntroductoryDemo Image
Setup2b6. Motion Properties - Inertia Tensor.unityDemo showing the effect of overriding inertia tensorIntroductoryDemo Image
Setup2b7. Motion Properties - Smoothing.unityDemo showing the effect of interpolation and extrapolationIntroductoryDemo Image
Setup2c1. Material Properties - Friction.unityShowing effect of different friction material valuesIntroductoryDemo Image
Setup2c2. Material Properties - Restitution.unityShowing effect of different restitution valuesIntroductoryDemo Image
Setup2c3. Material Properties - Collision Filters.unityShowing effect of different collision filtersIntroductoryDemo Image
Setup2d1. Events - Triggers.unityDemo demonstrating the usage of triggersIntroductoryDemo Image
Setup2d2. Events - Contacts.unityShowing effect of different contactsIntroductoryDemo Image
Query3a. All Hits Distance Test.unityDemo showing results of distance queries between multiple collidersIntroductoryDemo Image
Query3b. Cast Test.unityDemo showing the results of collider casting and ray castingIntroductoryDemo Image
Query3c. Closest Hit Distance Test.unityDemo showing results of distance queriesIntroductoryDemo Image
Query3d. Custom Collector.unityDemonstration of raycastIntroductoryDemo Image
Joints4a. Joints Parade.unityDemo showing a range of joint typesIntroductoryDemo Image
Joints4b. Limit DOF.unityShowing effect of limiting degrees of freedomIntroductoryDemo Image
Joints4c1. All Motors Parade.unityDemo showing different motorsIntroductoryDemo Image
Joints4c2. Position Motor.unityDemo showing position motorIntroductoryDemo Image
Joints4c3. Linear Velocity Motor.unityShowing linear velocity motorIntroductoryDemo Image
Joints4c4. Angular Velocity Motor.unityDemonstrating angular velocity motorIntroductoryDemo Image
Joints4c5. Rotational Motor.unityDemonstrating rotational motorIntroductoryDemo Image
Joints4d. Ragdolls.unityObligatory stack of ragdolls demoIntroductoryRagdoll
Joints4e. Single Ragdoll.unityGameObject ragdoll for Unity Physics (left) and built-in physics (right), created using the Ragdoll WizardIntroductoryDemo Image
Modify5a. Change Motion Type.unityDemo showing change of motion typeIntroductoryDemo Image
Modify5b. Change Box Collider Size.unityDemonstrating runtime change of collider sizeIntroductoryDemo Image
Modify5c. Change Collider Type.unityDemonstrating change of collider typeIntroductoryDemo Image
Modify5d. Change Velocity.unityDemo showing change of velocityIntroductoryDemo Image
Modify5e. Kinematic Motion.unityDemo showing kinematic motion in combination with dynamic objectsIntroductoryDemo Image
Modify5f. Change Surface Velocity.unityDemo showing change of surface velocityIntroductoryDemo Image
Modify5g1. Change Collider Material - Bouncy Boxes.unityDemo showing effect of unique prefab instantiation with collider material changesIntermediateDemo Image
Modify5g2. Unique Collider Blob Sharing.unityDemo showing effect of instantiating prefabs during runtime, making collider blobs unique and sharing collider blob dataAdvancedDemo Image
Modify5g3. Runtime Collider Creation.unityCreate mesh colliders during runtimeAdvancedModify colliders during runtime
Modify5g4. Runtime Collision Filter Modification.unityModify collision filters during runtimeAdvancedModify collision filters during runtime
Modify5g5. Modify Collider Geometry.unityModify collider geometry during runtimeAdvancedModify collider geometry during runtime
Modify5h. Change Scale.unityDemo showing scale change of entitiesIntroductoryDemo Image
Modify5i. Apply Impulse.unityDemo showing application of impulsesIntroductoryDemo Image
Modify5j. Modify Broadphase Pairs.unityFilter out collision by explicitly deleting pairs from broad phaseAdvancedModify broadphase Sample
Modify5k. Modify Contact Jacobians.unityModify the results of contact generation to produce special effectsAdvancedModify contacts
Modify5l. Modify Narrowphase Contacts.unityAdd new user contacts to simulation pipelineAdvancedModify Narrowphase contacts
Use Case6a. Character Controller.unityUser case demo showing a rudimentary FPS character controllerIntermediateCharacter Control
Use Case6b. Pool.unityDemonstration of calling immediate mode physicsIntermediateImmediate physics
Use Case6c. Planet Gravity.unityPerformance demo of asteroids around a planet using SP/HPIntroductoryPlanet Gravity
Use Case6d. Raycast Car.unityUser case demo showing a set of vehicle behaviorsIntermediateVehicles