mmmovania / BabylonPhysicsTutorials

A simple set of tutorials for getting up and running with physics in Babylon.js using Ammo.js physics engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BabylonPhysicsTutorials

A simple set of tutorials for getting up and running with physics in Babylon.js using Ammo.js physics engine. The following is the list of tutorials done so far.

  1. Simple Box (single box falling under gravity)
  2. Multiple Boxes (multiple boxes falling under gravity)
  3. Shooting (shows how to make a ball shoot in the viewing direction)
  4. Simple Joint (simple distance joint)
  5. Simple Ball (simple roll ball physics)
  6. Picking (raycast to pick meshes on mouse click)
  7. Bridge (simple bridge using hinge joints)
  8. Cloth (simple cloth modeled using soft body physics)
  9. Vehicle (simple car modelled using raycast physics)
  10. Tank (simple tank modelled using raycast physics)

Demo Details and Screenshots

Following are the details of the tutorial demos.

Simple Box

Shows how to add a single rigid body - Live Demo - Babylon.js Playground

alt text

Multiple Boxes

Shows how to add multiple rigid bodies - Live Demo - Babylon.js Playground

alt text

Shooting

Shows how to handle the left mouse click to launch projectile in the viewing direction for shooting balls on the boxes - Live Demo - Babylon.js Playground

alt text

Simple Joint

Shows how to add a simple point to point constraint - Live Demo - Babylon.js Playground

alt text

Simple Ball

Showing how to create rolling ball physics. This demo shows you how to make a ball roll on the ground using the keyboard keys

Controls:

Press 'w' to roll ball forward
Press 's' to roll ball backward
Press 'a' to roll ball to the left
Press 'd' to roll ball to the right

Live Demo - Babylon.js Playground

alt text

Picking

Shows how to use the left mouse button to pick a rigid body - Live Demo - Babylon.js Playground

alt text

Bridge

Shows how to use the hinge joint to make a bridge - Live Demo - Babylon.js Playground

alt text

Cloth

Shows how to make a cloth softbody - Live Demo - Babylon.js Playground

alt text

Vehicle

Shows how to make a vehicle

Controls:

Press 'w' to accelerate the car forward
Press 's' to decelerate the car backward
Press 'a' to turn the car left
Press 'd' to turn the car right

Live Demo - Babylon.js Playground

alt text

Tank

Shows how to make a tank using raycast vehicle. This demo is based on the excellent open source project: https://github.com/RuanLucasGD/Simple-Militay-Tank-Physics. The tank rig is also from the same repo. so a huge shout out to RuanLucasGD. The fbx was converted to gltf using the 3dsmax babylon exporter.

Controls:

Press 'w' to accelerate the tank forward
Press 's' to decelerate the tank backward
Press 'a' to turn the tank left
Press 'd' to turn the tank right
Press 'q' to lower the gun down
Press 'e' to lift the gun up
Press 'z' to turn the turret left
Press 'c' to turn the turret right

Live Simple Tank Demo - Babylon.js Playground

Click the image below to watch a youtube capture of the tank demo. Watch the video

Live Simple Tank Demo with Tracks using TrailMesh - Babylon.js Playground with Tracks using TrailMesh

alt text

About

A simple set of tutorials for getting up and running with physics in Babylon.js using Ammo.js physics engine

License:Apache License 2.0


Languages

Language:HTML 100.0%