2
0
Эх сурвалжийг харах

samples: revamp 01-physics

Daniele Bartolini 5 сар өмнө
parent
commit
cbe3bc7853
33 өөрчлөгдсөн 2222 нэмэгдсэн , 1748 устгасан
  1. 1 1
      samples/01-physics/boot.config
  2. 6 2
      samples/01-physics/boot.package
  3. 5 1
      samples/01-physics/global.physics_config
  4. 1402 0
      samples/01-physics/levels/mover.level
  5. 0 1382
      samples/01-physics/levels/test.level
  6. 239 48
      samples/01-physics/main.lua
  7. BIN
      samples/01-physics/sfx/ambient.ogg
  8. 3 0
      samples/01-physics/sfx/ambient.sound
  9. 3 0
      samples/01-physics/sfx/bounce.sound
  10. BIN
      samples/01-physics/sfx/bounce.wav
  11. 3 0
      samples/01-physics/sfx/shoot.sound
  12. BIN
      samples/01-physics/sfx/shoot.wav
  13. 50 0
      samples/01-physics/units/bullet/bullet.lua
  14. 57 0
      samples/01-physics/units/bullet/bullet.material
  15. 50 0
      samples/01-physics/units/bullet/bullet.unit
  16. 0 24
      samples/01-physics/units/cube.mesh
  17. 0 60
      samples/01-physics/units/cube.unit
  18. 57 0
      samples/01-physics/units/door_button/door_button.material
  19. 14 0
      samples/01-physics/units/grid.material
  20. 1 0
      samples/01-physics/units/grid.texture
  21. 59 0
      samples/01-physics/units/moving_platform/moving_platform.lua
  22. 57 0
      samples/01-physics/units/moving_platform/moving_platform.material
  23. 47 0
      samples/01-physics/units/moving_platform/moving_platform.unit
  24. 0 24
      samples/01-physics/units/plane.mesh
  25. 0 60
      samples/01-physics/units/plane.unit
  26. 0 24
      samples/01-physics/units/ramp.mesh
  27. 0 60
      samples/01-physics/units/ramp.unit
  28. 28 0
      samples/01-physics/units/sliding_door/sliding_door.unit
  29. 74 0
      samples/01-physics/units/sliding_door/sliding_door_trigger.lua
  30. 38 0
      samples/01-physics/units/sliding_door/sliding_door_trigger.unit
  31. 0 2
      samples/01-physics/units/sphere.mesh
  32. 0 60
      samples/01-physics/units/sphere.unit
  33. 28 0
      samples/01-physics/units/wall/wall.unit

+ 1 - 1
samples/01-physics/boot.config

@@ -23,6 +23,6 @@ windows = {
 }
 
 physics = {
-	step_frequency = 60
+	step_frequency = 240
 	max_substeps = 4
 }

+ 6 - 2
samples/01-physics/boot.package

@@ -9,10 +9,10 @@ physics_config = [
 ]
 unit = [
 	"core/units/camera"
-	"units/sphere"
+	"units/bullet/bullet"
 ]
 level = [
-	"levels/test"
+	"levels/mover"
 ]
 font = [
 	"core/game/hud/debug"
@@ -20,3 +20,7 @@ font = [
 material = [
 	"core/game/hud/debug"
 ]
+sound = [
+	"sfx/bounce"
+	"sfx/shoot"
+]

+ 5 - 1
samples/01-physics/global.physics_config

@@ -1,10 +1,14 @@
 materials = {
 	default = { friction = 0.8 rolling_friction = 0.5 restitution = 0.81 }
+	bullet = { friction = 0.8 rolling_friction = 0.5 restitution = 0.25 }
 }
 
 collision_filters = {
 	no_collision = { collides_with = [] }
-	default = { collides_with = [ "default" ] }
+	default = { collides_with = [ "default", "mover" "player" "bullet" ] }
+	mover = { collides_with = [ "default" ] }
+	player = { collides_with = [ "default" ] }
+	bullet = { collides_with = [ "default" "bullet" ] }
 }
 
 actors = {

+ 1402 - 0
samples/01-physics/levels/mover.level

@@ -0,0 +1,1402 @@
+_guid = "ba028395-428e-42f2-aca8-11a1523fe8bf"
+_type = "level"
+editor = {
+	camera = {
+		orthographic_size = 28.620796200000001
+		position = [
+			53.615696
+			-61.410461400000003
+			52.867267599999998
+		]
+		rotation = [
+			-0.31456348299999998
+			-0.107889466
+			0.305969983
+			0.89207178399999998
+		]
+		target_distance = 118.149109
+		view_type = 0
+	}
+}
+sounds = [
+	{
+		_guid = "8b0b2bd9-f3ac-4034-9c08-9f53e7e69f23"
+		_type = "sound_source"
+		editor = {
+			name = "background_noise"
+		}
+		group = "music"
+		loop = true
+		name = "sfx/ambient"
+		position = [
+			0
+			0
+			27.387899399999998
+		]
+		range = 1000
+		rotation = [
+			0
+			0
+			0
+			1
+		]
+		volume = 0.01
+	}
+]
+units = [
+	{
+		_guid = "1038946b-6df5-40b5-afbe-62540f403fed"
+		_type = "unit"
+		editor = {
+			name = "block4"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-31.812545799999999
+						20.933166499999999
+						4
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						8
+						8
+						8
+					]
+				}
+			}
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+				data = {
+					collision_filter = "default"
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "17a284b9-485c-4abd-9c7e-ec92b52e6d96"
+		_type = "unit"
+		editor = {
+			name = "sun"
+		}
+		modified_components = {
+			#3f6f6b7c-b4cf-4173-aab0-288a63d7c73a = {
+				data = {
+					position = [
+						12
+						6.5
+						52.167983999999997
+					]
+					rotation = [
+						0.21892799399999999
+						0.37359330099999999
+						0.064721733300000001
+						0.89906042799999997
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+				type = "transform"
+			}
+			#45e54fbe-018c-4ee2-917d-398c13bd3e7e = {
+				data = {
+					intensity = 1
+					type = "directional"
+				}
+			}
+			#65f81abd-43ea-4c15-8d96-b82fec868bcd = {
+				data = {
+					cast_shadows = false
+				}
+			}
+		}
+		prefab = "core/units/light"
+	}
+	{
+		_guid = "1f8c2281-53c5-48f4-93de-6a1b89c66140"
+		_type = "unit"
+		editor = {
+			name = "ground"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						0
+						0
+						0
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						150
+						150
+						1
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					material = "units/grid"
+				}
+			}
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+				data = {
+					class = "static"
+					collision_filter = "default"
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "28dc39ef-fd55-4023-8f6f-527fd2e4924c"
+		_type = "unit"
+		editor = {
+			name = "slope8"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-27.473960900000002
+						-18.035486200000001
+						5.1360974300000004
+					]
+					rotation = [
+						0.41562709199999998
+						0.415627152
+						0.57206165799999997
+						0.57206094299999999
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "2d58ad51-e1dd-4309-9552-676b6cdd8873"
+		_type = "unit"
+		editor = {
+			name = "trigger_wall_R"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						30.3070621
+						27.8795395
+						3.5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						6.25
+						1
+						6
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "2e42b505-2b95-475d-882f-158d2b5fbeff"
+		_type = "unit"
+		editor = {
+			name = "raycast_wall_R"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						51.204612699999998
+						27.8795395
+						3.5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						6.25
+						1
+						6
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "2f166dbf-5e6a-4d34-9a58-a6228c453fdf"
+		_type = "unit"
+		components = [
+			{
+				_guid = "1d768085-0b0a-4e40-9d77-f9e73117ac1c"
+				_type = "script"
+				data = {
+					script_resource = "units/sliding_door/sliding_door_trigger"
+				}
+			}
+		]
+		editor = {
+			name = "trigger_trigger"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						26.0570621
+						27.8795395
+						3.5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						2.5
+						12
+						6
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					visible = false
+				}
+			}
+		}
+		prefab = "units/sliding_door/sliding_door_trigger"
+	}
+	{
+		_guid = "3abacaaf-a98b-4da8-b48b-e3a751dc7d12"
+		_type = "unit"
+		editor = {
+			name = "trigger_door"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						26.057100299999998
+						27.8795395
+						2.5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						2.5
+						0.5
+						4
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					material = "units/moving_platform/moving_platform"
+				}
+			}
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+				data = {
+					class = "keyframed"
+				}
+			}
+		}
+		prefab = "units/sliding_door/sliding_door"
+	}
+	{
+		_guid = "3c60e9fa-cd22-4834-9bdc-dc318be4d008"
+		_type = "unit"
+		editor = {
+			name = "moving_platform"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-13.812545800000001
+						32.933166499999999
+						0.75
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						4
+						4
+						0.5
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					material = "units/moving_platform/moving_platform"
+				}
+			}
+		}
+		prefab = "units/moving_platform/moving_platform"
+	}
+	{
+		_guid = "43223c75-082a-48a3-b23f-87fd75558ac4"
+		_type = "unit"
+		editor = {
+			name = "slope5"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-29.406623799999998
+						-27.035486200000001
+						3.89736605
+					]
+					rotation = [
+						0.270598173
+						0.27059826300000001
+						0.65328156900000001
+						0.653281271
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "48c4c8c9-fa8d-4a8f-829c-3ea346cd8e93"
+		_type = "unit"
+		editor = {
+			name = "wall3"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						0
+						-75
+						5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						150
+						1
+						10
+					]
+				}
+			}
+		}
+		prefab = "units/wall/wall"
+	}
+	{
+		_guid = "4dd83d1c-e3af-4c5c-b0a3-af81e299b938"
+		_type = "unit"
+		editor = {
+			name = "slope9"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-26.720108
+						-15.035486199999999
+						5.3436970700000002
+					]
+					rotation = [
+						0.45922932
+						0.45922938000000002
+						0.53768795700000005
+						0.53768813599999998
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "6cc5073c-2eff-4e24-990c-0433aad3a792"
+		_type = "unit"
+		editor = {
+			name = "slope7"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-28.189094499999999
+						-21.035486200000001
+						4.8579101600000003
+					]
+					rotation = [
+						0.36946225199999999
+						0.36946245999999999
+						0.60290771700000001
+						0.60290747899999997
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "6e9129fb-979a-4bb2-93d1-e497fe05e108"
+		_type = "unit"
+		editor = {
+			name = "moving_platform2"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-31.812545799999999
+						14.9331665
+						7.75
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						4
+						4
+						0.5
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					material = "units/moving_platform/moving_platform"
+				}
+			}
+		}
+		prefab = "units/moving_platform/moving_platform"
+	}
+	{
+		_guid = "70ecc3f3-b319-4884-bbdc-29f56fd0e948"
+		_type = "unit"
+		editor = {
+			name = "trigger_wall_L"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						21.8070621
+						27.8795395
+						3.5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						6.25
+						1
+						6
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "71225ea8-e1e4-4b91-9a7d-02e52dd35b4d"
+		_type = "unit"
+		deleted_components = {
+			#08b8b97a-c894-409f-8f57-e7508ff8d3cf = false
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = false
+		}
+		editor = {
+			name = "label_trigger"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						25.944591500000001
+						27.888225599999998
+						6.9713425600000001
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					visible = false
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "760a20bb-8926-4a79-a2eb-7676b681afb3"
+		_type = "unit"
+		editor = {
+			name = "slope6"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-28.836074799999999
+						-24.035486200000001
+						4.4291534400000003
+					]
+					rotation = [
+						0.32101997700000001
+						0.32101988799999998
+						0.63003647299999999
+						0.63003695000000004
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "7fb42433-4779-4e85-bd77-6269ec4b0044"
+		_type = "unit"
+		editor = {
+			name = "raycast_wall_L"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						42.704612699999998
+						27.8795395
+						3.5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						6.25
+						1
+						6
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "842a6cca-ad96-4db3-bf96-ea8dc4ce47ad"
+		_type = "unit"
+		deleted_components = {
+			#08b8b97a-c894-409f-8f57-e7508ff8d3cf = false
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = false
+		}
+		editor = {
+			name = "label_moving_platforms"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-25.325752300000001
+						27.169219999999999
+						6.9713425600000001
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					visible = false
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "89cb990c-6a37-47cc-a001-c9b5ea5965dd"
+		_type = "unit"
+		editor = {
+			name = "cube"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						48.773925800000001
+						27.663141299999999
+						2.5272736500000001
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						0.41285723400000002
+						0.239813417
+						0.41285723400000002
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "8eaa5f55-fcf4-4766-bfbe-411f38635444"
+		_type = "unit"
+		editor = {
+			name = "raycast_door"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						46.954650899999997
+						27.8795395
+						2.5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						2.5
+						0.5
+						4
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					material = "units/moving_platform/moving_platform"
+				}
+			}
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+				data = {
+					class = "keyframed"
+				}
+			}
+		}
+		prefab = "units/sliding_door/sliding_door"
+	}
+	{
+		_guid = "9c51dbcc-c19d-4653-9402-ad705b86fc49"
+		_type = "unit"
+		editor = {
+			name = "wall2"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-75.000015300000001
+						-3.3915042900000002e-05
+						5
+					]
+					rotation = [
+						0
+						0
+						-0.70710658999999998
+						0.70710694799999996
+					]
+					scale = [
+						150
+						1
+						10
+					]
+				}
+			}
+		}
+		prefab = "units/wall/wall"
+	}
+	{
+		_guid = "9fa2f375-6a18-41c2-85a4-64bbf76b896f"
+		_type = "unit"
+		editor = {
+			name = "block3"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-19.812545799999999
+						32.933166499999999
+						4
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						8
+						8
+						8
+					]
+				}
+			}
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+				data = {
+					collision_filter = "default"
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "a1cf5c67-79f5-4136-98aa-36a6e8da63b4"
+		_type = "unit"
+		editor = {
+			name = "wall4"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						74.999969500000006
+						1.8239021300000002e-05
+						5
+					]
+					rotation = [
+						0
+						0
+						0.70710682899999999
+						0.70710670900000006
+					]
+					scale = [
+						150
+						1
+						10
+					]
+				}
+			}
+		}
+		prefab = "units/wall/wall"
+	}
+	{
+		_guid = "a95e1743-5950-4ddf-8e47-37dcecbec6e1"
+		_type = "unit"
+		deleted_components = {
+			#08b8b97a-c894-409f-8f57-e7508ff8d3cf = false
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = false
+		}
+		editor = {
+			name = "label_raycast"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						46.7861099
+						27.888225599999998
+						6.9713425600000001
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					visible = false
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "aac99e47-1eac-4d65-9bcd-1ee6070a51c1"
+		_type = "unit"
+		editor = {
+			name = "unit_0000"
+		}
+		modified_components = {
+			#3f6f6b7c-b4cf-4173-aab0-288a63d7c73a = {
+				data = {
+					position = [
+						-12.812545800000001
+						22
+						26.1616669
+					]
+					rotation = [
+						0.099045813100000005
+						0.23911780099999999
+						-0.369643897
+						0.89239901300000002
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+			}
+			#45e54fbe-018c-4ee2-917d-398c13bd3e7e = {
+				data = {
+					range = 60
+					type = "spot"
+				}
+			}
+		}
+		prefab = "core/units/light"
+	}
+	{
+		_guid = "b4c8b719-6ade-45a2-bff3-cdca02599263"
+		_type = "unit"
+		editor = {
+			name = "shading_environment"
+		}
+		modified_components = {
+			#01669b61-1acb-4c6d-bef5-98ddf699a895 = {
+				data = {
+					density = 0.01
+					enabled = false
+					range_min = 60
+				}
+			}
+			#58d8d3ed-9ec2-4e11-ade6-1a3860335bb6 = {
+				data = {
+					enabled = true
+					weight = 0.050000000000000003
+				}
+			}
+			#6603b89f-a049-4c18-a9de-7fc31368eeb5 = {
+				data = {
+					ambient_color = [
+						0.21233333333333337
+						0.26430303030303026
+						0.32666666666666666
+					]
+					skydome_intensity = 2
+				}
+			}
+			#f7fb0c3b-aaeb-4ea6-a210-0c5130e4352a = {
+				data = {
+					type = "filmic"
+				}
+			}
+		}
+		prefab = "core/renderer/default_shading_environment"
+	}
+	{
+		_guid = "bcb2bc03-d313-4741-a28d-12a6d0d8196f"
+		_type = "unit"
+		components = [
+			{
+				_global_physics_config = "global"
+				_guid = "1fb2f570-d5d6-4764-9255-2bbc5b9b584c"
+				_type = "actor"
+				data = {
+					class = "keyframed"
+					collision_filter = "player"
+					lock_rotation_x = false
+					lock_rotation_y = false
+					lock_rotation_z = false
+					lock_translation_x = false
+					lock_translation_y = false
+					lock_translation_z = false
+					mass = 1
+					material = "default"
+				}
+			}
+			{
+				_global_physics_config = "global"
+				_guid = "75b497d8-f6b7-4890-959e-eba397df66e0"
+				_type = "mover"
+				data = {
+					collision_filter = "mover"
+					height = 1.8
+					max_slope_angle = 0.78539816339744828
+					max_step_height = 0.80000000000000004
+					radius = 0.5
+				}
+			}
+			{
+				_guid = "df813664-3436-4816-840f-68286b4a74db"
+				_type = "collider"
+				data = {
+					collider_data = {
+						half_extents = [
+							0
+							0
+							0
+						]
+						height = 0
+						position = [
+							0
+							0
+							0
+						]
+						radius = 0
+						rotation = [
+							0
+							0
+							0
+							1
+						]
+					}
+					name = "Cube"
+					scene = "core/units/primitives/cube"
+					shape = "box"
+					source = "mesh"
+				}
+			}
+		]
+		deleted_components = {
+			#08b8b97a-c894-409f-8f57-e7508ff8d3cf = false
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = false
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = false
+		}
+		editor = {
+			name = "character"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						0
+						0
+						7.3938693999999998
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "cab5ed48-5f74-4819-b59d-9e6e82ccfb44"
+		_type = "unit"
+		editor = {
+			name = "wall"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						0
+						75
+						5
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						150
+						1
+						10
+					]
+				}
+			}
+		}
+		prefab = "units/wall/wall"
+	}
+	{
+		_guid = "d19b201e-b7c8-4d62-8522-cc6a1325a3ef"
+		_type = "unit"
+		editor = {
+			name = "camera"
+		}
+		modified_components = {
+			#1d578001-d96b-4b0e-90a9-181b32161a7d = {
+				data = {
+					position = [
+						-1.06499875
+						-38.759468099999999
+						13.3709946
+					]
+					rotation = [
+						-0.25907540299999998
+						0.0052471254000000002
+						-0.019557464900000002
+						0.96564483599999995
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+			}
+		}
+		prefab = "core/units/camera"
+	}
+	{
+		_guid = "d5fb7547-c3e8-41de-a81b-36c4ac2ad942"
+		_type = "unit"
+		editor = {
+			name = "slope4"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-29.8905411
+						-30.035486200000001
+						3.2688131299999998
+					]
+					rotation = [
+						0.21850799000000001
+						0.21850815400000001
+						0.67249864299999995
+						0.67249834500000005
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "d8982d9a-28cf-413c-9461-836a83da8114"
+		_type = "unit"
+		editor = {
+			name = "block2"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-31.812545799999999
+						32.933166499999999
+						4
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						8
+						8
+						8
+					]
+				}
+			}
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+				data = {
+					collision_filter = "default"
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "dd7ba069-6acc-4a8b-aeaf-d7028bd9fabc"
+		_type = "unit"
+		editor = {
+			name = "block"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-19.812545799999999
+						20.933166499999999
+						4
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						8
+						8
+						8
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					cast_shadows = true
+					visible = true
+				}
+			}
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+				data = {
+					collision_filter = "default"
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "ddfb4a06-1f4a-4525-8b1c-2a32a8face17"
+		_type = "unit"
+		editor = {
+			name = "slope2"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-30.524131799999999
+						-36.0354843
+						1.8945908499999999
+					]
+					rotation = [
+						0.11061586399999999
+						0.11061589400000001
+						0.69840127200000002
+						0.69840097400000001
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "ef853e6b-be47-49db-b9a6-d1c482ac6fca"
+		_type = "unit"
+		editor = {
+			name = "raycast_door_button"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						48.671798699999997
+						27.350269300000001
+						1.9429852999999999
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						0.41557213700000001
+						0.124079011
+						0.41557213700000001
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					cast_shadows = false
+					material = "units/door_button/door_button"
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "f452521d-6d98-4326-9f7f-1eb908c98c6b"
+		_type = "unit"
+		deleted_components = {
+			#08b8b97a-c894-409f-8f57-e7508ff8d3cf = false
+			#b15082c5-3aaf-4c9a-8925-e5c958d49171 = false
+		}
+		editor = {
+			name = "label_slopes"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-29.370750399999999
+						-27.033748599999999
+						6.9713425600000001
+					]
+					rotation = [
+						0
+						0
+						0
+						1
+					]
+					scale = [
+						1
+						1
+						1
+					]
+				}
+			}
+			#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+				data = {
+					visible = false
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "f50c8bce-906b-447d-8569-0f32be8cb92e"
+		_type = "unit"
+		editor = {
+			name = "slope"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-30.6150436
+						-39.0354843
+						1.1316375700000001
+					]
+					rotation = [
+						0.055478997500000002
+						0.055479038500000001
+						0.70492732499999999
+						0.70492672899999997
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+	{
+		_guid = "f7b1250c-a5f0-456b-8109-9e75fd7b40ee"
+		_type = "unit"
+		editor = {
+			name = "slope3"
+		}
+		modified_components = {
+			#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+				data = {
+					position = [
+						-30.273147600000001
+						-33.0354843
+						2.6138231799999998
+					]
+					rotation = [
+						0.165070891
+						0.16507086200000001
+						0.68756920099999996
+						0.68756949899999997
+					]
+					scale = [
+						2
+						10
+						0.25
+					]
+				}
+			}
+		}
+		prefab = "core/units/primitives/cube"
+	}
+]

+ 0 - 1382
samples/01-physics/levels/test.level

@@ -1,1382 +0,0 @@
-_guid = "d67463da-f179-4eb4-849c-0f7fc5e63e34"
-_type = "level"
-sounds = [
-]
-units = [
-	{
-		_guid = "0365e3df-a7ac-4f49-87de-f1b9bdf3f958"
-		_type = "unit"
-		editor = {
-			name = "unit_0008"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						4
-						-4
-						7.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "04f23df8-d4fc-4ebc-811b-42f843499c79"
-		_type = "unit"
-		editor = {
-			name = "unit_0001"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						2
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "05757636-12a1-48b0-9ade-59cc3d9bb19c"
-		_type = "unit"
-		editor = {
-			name = "unit_0002"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-2
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "0bd39883-476e-4193-b750-1484ecedd959"
-		_type = "unit"
-		editor = {
-			name = "unit_0000"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						8
-						-4
-						1.0491999999999999
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "0c8b1474-8e72-44ee-9189-86c84a3dcfda"
-		_type = "unit"
-		editor = {
-			name = "unit_0003"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-4
-						-4
-						5.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "0cae3b7c-23a1-454c-802d-5fce8b84093f"
-		_type = "unit"
-		editor = {
-			name = "unit_0004"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						6
-						-4
-						5.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "0e164588-c310-4c41-9e04-e9c9a2044c6b"
-		_type = "unit"
-		editor = {
-			name = "unit_0005"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-8
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "0f234f5f-7ac3-4fb5-809d-54e83e849253"
-		_type = "unit"
-		editor = {
-			name = "unit_0006"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						4
-						-4
-						5.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "1f04201a-debf-4320-964f-de8d8764d37d"
-		_type = "unit"
-		editor = {
-			name = "unit_0007"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-6
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "29f29073-bd6d-457e-8912-de80e0994ffc"
-		_type = "unit"
-		editor = {
-			name = "unit_0009"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-2
-						-4
-						5.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "3282fd34-1c42-49cc-8014-4a1e941de86a"
-		_type = "unit"
-		editor = {
-			name = "unit_0011"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						2
-						-4
-						5.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "37e02b71-55d3-4913-86ea-dc80b19c024c"
-		_type = "unit"
-		editor = {
-			name = "unit_0012"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						4
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "3ce1462b-dd86-4c6c-b26d-114154aed730"
-		_type = "unit"
-		editor = {
-			name = "unit_0013"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-4
-						-4
-						7.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "5fe4cf4f-1f5c-4af4-816f-c563f316fd44"
-		_type = "unit"
-		editor = {
-			name = "unit_0014"
-		}
-		modified_components = {
-			#805e9323-578b-4d22-8414-b15b1a5ff7bc = {
-				data = {
-					position = [
-						-256
-						0
-						-230
-					]
-					rotation = [
-						0.70710664999999995
-						2.1073413199999999e-08
-						0.70710688799999999
-						2.1073420299999999e-08
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/plane"
-	}
-	{
-		_guid = "663ef523-b073-424b-9cd4-546680541377"
-		_type = "unit"
-		editor = {
-			name = "unit_0015"
-		}
-		modified_components = {
-			#805e9323-578b-4d22-8414-b15b1a5ff7bc = {
-				data = {
-					position = [
-						0
-						256
-						-230
-					]
-					rotation = [
-						2.10734274e-08
-						-0.70710682899999999
-						0.70710682899999999
-						-2.1073425700000001e-08
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/plane"
-	}
-	{
-		_guid = "683c5131-06e1-4dad-96cd-3ef6d573d9bf"
-		_type = "unit"
-		editor = {
-			name = "sun"
-		}
-		modified_components = {
-			#3f6f6b7c-b4cf-4173-aab0-288a63d7c73a = {
-				data = {
-					position = [
-						-22.788524599999999
-						-41.973369599999998
-						72.825294499999998
-					]
-					rotation = [
-						0.42008671199999997
-						-0.0187445693
-						-0.0988142937
-						0.90189331800000005
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-			#45e54fbe-018c-4ee2-917d-398c13bd3e7e = {
-				data = {
-					color = [
-						1
-						1
-						1
-					]
-					intensity = 5
-					range = 15
-					spot_angle = 0.52359900000000004
-					type = "directional"
-				}
-			}
-		}
-		prefab = "core/units/light"
-	}
-	{
-		_guid = "70d2d5c4-e1ee-4458-aaff-9950341162cf"
-		_type = "unit"
-		editor = {
-			name = "unit_0016"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						0
-						-4
-						7.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "747d5b75-f1b4-476d-af74-8fabaf475cd6"
-		_type = "unit"
-		editor = {
-			name = "unit_0017"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						2
-						-4
-						7.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "764eb24e-9947-4d94-a814-2c26c1477892"
-		_type = "unit"
-		editor = {
-			name = "unit_0018"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						6
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "7af7b904-9f6f-4d23-a202-03ece3887bb5"
-		_type = "unit"
-		editor = {
-			name = "unit_0019"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-2
-						-4
-						9.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "809dc860-5b63-4850-8637-9da2d0cae323"
-		_type = "unit"
-		editor = {
-			name = "unit_0020"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						4
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "8537c3c6-dfc6-4c8d-a91c-e7f4ec4fa3e5"
-		_type = "unit"
-		editor = {
-			name = "unit_0021"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-10
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "88d290eb-62ea-44e2-860f-16a18e428a65"
-		_type = "unit"
-		editor = {
-			name = "unit_0022"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						8
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "9ab38fec-f03e-475f-a07c-98c618fab522"
-		_type = "unit"
-		editor = {
-			name = "unit_0023"
-		}
-		modified_components = {
-			#805e9323-578b-4d22-8414-b15b1a5ff7bc = {
-				data = {
-					position = [
-						256
-						0
-						-230
-					]
-					rotation = [
-						0.70710694799999996
-						1.05367093e-07
-						-0.70710658999999998
-						-1.2644052599999999e-07
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/plane"
-	}
-	{
-		_guid = "9c35713a-b50a-4c4d-9338-44eb2913d61c"
-		_type = "unit"
-		editor = {
-			name = "unit_0024"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-8
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "a29ecd27-9cb5-4f2f-a417-d32b93cfb615"
-		_type = "unit"
-		editor = {
-			name = "unit_0025"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-4
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "ab4b8ed6-780a-4d3a-86fe-d8345bdd2226"
-		_type = "unit"
-		editor = {
-			name = "unit_0026"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						0
-						-4
-						11.049200000000001
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "b1827eaa-4222-450c-866c-d719354e0b0b"
-		_type = "unit"
-		editor = {
-			name = "unit_0027"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						2
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "b1cbf05e-c348-41a0-8677-eff4e1d35987"
-		_type = "unit"
-		editor = {
-			name = "camera"
-		}
-		modified_components = {
-			#1d578001-d96b-4b0e-90a9-181b32161a7d = {
-				data = {
-					position = [
-						0
-						-30
-						6.5
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-			}
-		}
-		prefab = "core/units/camera"
-	}
-	{
-		_guid = "b38e2246-4aa1-4fea-954b-71c21b39415f"
-		_type = "unit"
-		editor = {
-			name = "unit_0028"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-4
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "ba450bf1-ab65-4ccb-8889-1d8b20bad417"
-		_type = "unit"
-		editor = {
-			name = "unit_0029"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-2
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "ba8d7ab5-8d00-46bf-9740-c6bfd6f1a95d"
-		_type = "unit"
-		editor = {
-			name = "ground"
-		}
-		modified_components = {
-			#805e9323-578b-4d22-8414-b15b1a5ff7bc = {
-				data = {
-					position = [
-						0
-						0
-						0
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/plane"
-	}
-	{
-		_guid = "c100421b-79c1-43b8-8790-dd71960bafa9"
-		_type = "unit"
-		editor = {
-			name = "unit_0031"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						10
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "c48604c3-e761-415b-b83c-4a1eaa1a42f8"
-		_type = "unit"
-		editor = {
-			name = "unit_0032"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						2
-						-4
-						9.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "cb332d1a-6b79-4204-b288-d3b059138e57"
-		_type = "unit"
-		editor = {
-			name = "unit_0033"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						0
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "ce46276d-06fe-4b1f-b400-452965e66d49"
-		_type = "unit"
-		editor = {
-			name = "ramp"
-		}
-		modified_components = {
-			#1089a8ef-c51f-417d-9160-3716b5b441d7 = {
-				data = {
-					position = [
-						0
-						20
-						0
-					]
-					rotation = [
-						0
-						0
-						-0.70710682899999999
-						0.70710670900000006
-					]
-					scale = [
-						8
-						9
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/ramp"
-	}
-	{
-		_guid = "cf5c2f17-d515-4e05-b9b3-a6297d050544"
-		_type = "unit"
-		editor = {
-			name = "unit_0035"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-2
-						-4
-						7.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "d508c0b1-3e22-4fa4-af59-fbdbeb1a68e8"
-		_type = "unit"
-		editor = {
-			name = "unit_0036"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-6
-						-4
-						5.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "d52ad0e5-5798-4037-8494-ca23a013fdab"
-		_type = "unit"
-		editor = {
-			name = "unit_0037"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						0
-						-4
-						9.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "d95eca3d-21f9-40fa-b218-e0c52b2327c7"
-		_type = "unit"
-		editor = {
-			name = "unit_0038"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						0
-						-4
-						1.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "e0398eaa-22ee-453f-a016-b768d95a8785"
-		_type = "unit"
-		editor = {
-			name = "unit_0039"
-		}
-		modified_components = {
-			#805e9323-578b-4d22-8414-b15b1a5ff7bc = {
-				data = {
-					position = [
-						-2.52724003e-05
-						-256
-						-230
-					]
-					rotation = [
-						-2.10734274e-08
-						0.70710682899999999
-						0.70710682899999999
-						-2.1073425700000001e-08
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/plane"
-	}
-	{
-		_guid = "e31c8dde-f80b-4bba-80fb-6d263df32ab8"
-		_type = "unit"
-		editor = {
-			name = "unit_0040"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						0
-						-4
-						5.0492100000000004
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "e53ca129-4bc4-4cd3-9627-8962f4acc1e1"
-		_type = "unit"
-		editor = {
-			name = "unit_0041"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						-6
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-	{
-		_guid = "ea7b8639-190b-42aa-b581-004ae990434a"
-		_type = "unit"
-		editor = {
-			name = "unit_0042"
-		}
-		modified_components = {
-			#f56420ad-7f9c-4cca-aca5-350f366e0dc0 = {
-				data = {
-					position = [
-						6
-						-4
-						3.04921
-					]
-					rotation = [
-						0
-						0
-						0
-						1
-					]
-					scale = [
-						1
-						1
-						1
-					]
-				}
-				type = "transform"
-			}
-		}
-		prefab = "units/cube"
-	}
-]

+ 239 - 48
samples/01-physics/main.lua

@@ -4,95 +4,286 @@
 require "core/game/camera"
 
 Game = Game or {
-	pw = nil,
-	rw = nil,
-	sg = nil,
+	physics_world = nil,
+	render_world = nil,
+	scene_graph = nil,
+	camera = nil,
+	world_gui = nil,
+	cursor_disabled = false,
+
+	-- Player movement.
+	character_unit = nil,
+	gravity = 6*9.8,
+	vertical_speed = 0,
+	walk_speed = 8,
+	run_multiplier = 1.8,
+
+	-- Bullets management.
+	max_bullets = 20,
+	num_bullets = 0,
+	bullets_head = 1,
+	bullets_tail = 1,
+	bullets = {},
+	ages = {},
+
+	-- Actionable door.
+	door_open = false,
+
+	-- Debug.
 	debug_graphics = false,
 	debug_physics = false,
-	camera = nil,
-	cursor = { modes = { "normal", "disabled"}, current_mode = 1 },
 }
 
 GameBase.game = Game
-GameBase.game_level = "levels/test"
+GameBase.game_level = "levels/mover"
+GameBase.show_help = true
 
 function Game.level_loaded()
-	Game.pw = World.physics_world(GameBase.world)
-	Game.rw = World.render_world(GameBase.world)
-	Game.sg = World.scene_graph(GameBase.world)
+	Game.physics_world = World.physics_world(GameBase.world)
+	Game.render_world = World.render_world(GameBase.world)
+	Game.scene_graph = World.scene_graph(GameBase.world)
 	Game.camera = FPSCamera(GameBase.world, GameBase.camera_unit)
+	Game.world_gui = World.create_world_gui(GameBase.world)
+
+	-- Create character controller.
+	Game.character_unit = World.unit_by_name(GameBase.world, "character")
+
+	-- Link camera to mover.
+	if Game.character_unit then
+		local character_transform = SceneGraph.instance(Game.scene_graph, Game.character_unit)
+		local camera_transform    = SceneGraph.instance(Game.scene_graph, GameBase.camera_unit)
+
+		if SceneGraph.parent(Game.scene_graph, camera_transform) == nil then
+			SceneGraph.link(Game.scene_graph, character_transform, camera_transform)
+		end
+	end
+
+	-- Create a pool of reusable bullets.
+	for i=1, Game.max_bullets do
+		local bullet_unit = World.spawn_unit(GameBase.world, "units/bullet/bullet", Vector3(0, 0, -100))
+		local bullet_actor = PhysicsWorld.actor_instance(Game.physics_world, bullet_unit)
+
+		-- Avoid overlapping bullets interaction.
+		PhysicsWorld.actor_disable_gravity(Game.physics_world, bullet_actor)
+		PhysicsWorld.actor_disable_collision(Game.physics_world, bullet_actor)
+
+		Game.bullets[i] = bullet_unit
+		Game.ages[i] = 0
+	end
 
 	-- Debug.
-	PhysicsWorld.enable_debug_drawing(Game.pw, Game.debug_physics)
-	RenderWorld.enable_debug_drawing(Game.rw, Game.debug_graphics)
+	PhysicsWorld.enable_debug_drawing(Game.physics_world, Game.debug_physics)
+	RenderWorld.enable_debug_drawing(Game.render_world, Game.debug_graphics)
 end
 
 function Game.update(dt)
-	-- Stop the engine when the 'ESC' key is released.
-	if Keyboard.released(Keyboard.button_id("escape")) then
-		Device.quit()
+	-- Toggle cursor state and quit logic.
+	if Keyboard.any_pressed() then
+		if Keyboard.pressed(Keyboard.button_id("escape")) then
+			if Game.cursor_disabled then
+				Window.set_cursor_mode("normal")
+				Game.cursor_disabled = false
+			else
+				Device.quit()
+			end
+		else
+			Window.set_cursor_mode("disabled")
+			Game.cursor_disabled = true
+		end
 	end
 
-	-- Toggle debug drawing.
-	if Keyboard.released(Keyboard.button_id("z")) then
-		Game.debug_physics = not Game.debug_physics
-		PhysicsWorld.enable_debug_drawing(Game.pw, Game.debug_physics)
-	end
+	local camera_world = Game.camera:world_pose()
+	World.set_listener_pose(GameBase.world, camera_world)
 
-	if Keyboard.released(Keyboard.button_id("x")) then
-		Game.debug_graphics = not Game.debug_graphics
-		RenderWorld.enable_debug_drawing(Game.rw, Game.debug_graphics)
+	-- Recycle used bullets after they expire.
+	local head = Game.bullets_head
+	for i=1, Game.num_bullets do
+		if Game.ages[head] < 4 then
+			Game.ages[head] = Game.ages[head] + dt
+			head = head % Game.max_bullets + 1
+		else
+			local bullet_unit = Game.bullets[Game.bullets_head]
+			local bullet_actor = PhysicsWorld.actor_instance(Game.physics_world, bullet_unit)
+
+			-- Avoid overlapping bullets interaction.
+			PhysicsWorld.actor_disable_gravity(Game.physics_world, bullet_actor)
+			PhysicsWorld.actor_disable_collision(Game.physics_world, bullet_actor)
+
+			-- Bullets may have been recycled while still in motion.
+			PhysicsWorld.actor_set_linear_velocity(Game.physics_world, bullet_actor, Vector3.zero())
+			PhysicsWorld.actor_set_angular_velocity(Game.physics_world, bullet_actor, Vector3.zero())
+
+			-- Teleport bullet somewhere player can't see it.
+			PhysicsWorld.actor_teleport_world_position(Game.physics_world, bullet_actor, Vector3(0, 0, -100))
+
+			Game.ages[Game.bullets_head] = 0
+			Game.bullets_head = Game.bullets_head % Game.max_bullets + 1
+			Game.num_bullets = Game.num_bullets - 1
+		end
 	end
 
-	-- Shoot a sphere when left mouse button is pressed.
+	-- Shoot a bullet when left mouse button is pressed.
 	if Mouse.pressed(Mouse.button_id("left")) then
-		local tr = SceneGraph.instance(Game.sg, Game.camera:unit())
-		local pos = SceneGraph.local_position(Game.sg, tr)
-		local dir = Matrix4x4.y(SceneGraph.local_pose(Game.sg, tr))
-		local u1 = World.spawn_unit(GameBase.world, "units/sphere", pos)
-		local a1 = PhysicsWorld.actor_instance(Game.pw, u1)
+		local tr = SceneGraph.instance(Game.scene_graph, Game.camera:unit())
+		local pos = SceneGraph.world_position(Game.scene_graph, tr)
+		local dir = Matrix4x4.y(SceneGraph.local_pose(Game.scene_graph, tr))
 		Vector3.normalize(dir)
-		PhysicsWorld.actor_add_impulse(Game.pw, a1, dir * 500.0)
+
+		if Game.num_bullets == Game.max_bullets then
+			-- Empty magazine. Play a sad sound maybe.
+		else
+			local bullet_unit = Game.bullets[Game.bullets_tail]
+			local bullet_actor = PhysicsWorld.actor_instance(Game.physics_world, bullet_unit)
+
+			-- Gravity and collision is disabled when the bullet gets recycled. Re-enable both.
+			PhysicsWorld.actor_enable_gravity(Game.physics_world, bullet_actor)
+			PhysicsWorld.actor_enable_collision(Game.physics_world, bullet_actor)
+
+			-- Move the bullet in front of player and shoot it forward.
+			PhysicsWorld.actor_teleport_world_position(Game.physics_world, bullet_actor, pos + dir * 1.5)
+			PhysicsWorld.actor_add_impulse(Game.physics_world, bullet_actor, dir * 50.0)
+
+			World.play_sound(GameBase.world, "sfx/shoot", false, 0.6)
+
+			Game.bullets_tail = Game.bullets_tail % Game.max_bullets + 1
+			Game.num_bullets = Game.num_bullets + 1
+		end
 	end
 
-	-- Perform a raycast when middle mouse button is pressed.
-	if Mouse.pressed(Mouse.button_id("middle")) then
-		local tr = SceneGraph.instance(Game.sg, Game.camera:unit())
-		local pos = SceneGraph.local_position(Game.sg, tr)
-		local dir = Matrix4x4.y(SceneGraph.local_pose(Game.sg, tr))
-		local hit, pos, normal, time, unit, actor = PhysicsWorld.cast_ray(Game.pw, pos, dir, 100)
+	-- Actionable door.
+	if Keyboard.pressed(Keyboard.button_id("e")) then
+		local camera_transform = SceneGraph.instance(Game.scene_graph, Game.camera:unit())
+		local camera_position = SceneGraph.world_position(Game.scene_graph, camera_transform)
+		local camera_forward = Matrix4x4.y(SceneGraph.world_pose(Game.scene_graph, camera_transform))
+		local hit, hit_pos, normal, time, unit, actor = PhysicsWorld.cast_ray(Game.physics_world, camera_position, camera_forward, 100)
+
 		if hit then
-			PhysicsWorld.actor_add_impulse(Game.pw, actor, dir * 400.0)
+			local door_button = World.unit_by_name(GameBase.world, "raycast_door_button")
+
+			-- If we hit the door button and we are not too far, open/close the door.
+			if unit == door_button and Vector3.distance(camera_position, hit_pos) < 10 then
+				local door = World.unit_by_name(GameBase.world, "raycast_door")
+				local door_transform = SceneGraph.instance(Game.scene_graph, door)
+				local door_position = SceneGraph.local_position(Game.scene_graph, door_transform)
+				local door_dx = 2.3
+				local new_door_position = door_position + Vector3(Game.door_open and door_dx or -door_dx, 0, 0)
+
+				SceneGraph.set_local_position(Game.scene_graph, door_transform, new_door_position)
+				Game.door_open = not Game.door_open
+			end
 		end
 	end
 
-	-- Toggle mouse cursor modes.
-	if Keyboard.released(Keyboard.button_id("space")) then
-		Game.cursor.current_mode = 1 + Game.cursor.current_mode % #Game.cursor.modes
-		Window.set_cursor_mode(Game.cursor.modes[Game.cursor.current_mode])
+	local dx = Keyboard.button(Keyboard.button_id("d")) - Keyboard.button(Keyboard.button_id("a"))
+	local dy = Keyboard.button(Keyboard.button_id("w")) - Keyboard.button(Keyboard.button_id("s"))
+
+	if Game.character_unit then
+		local mover = PhysicsWorld.mover_instance(Game.physics_world, Game.character_unit)
+
+		-- Player mover.
+		local coll_sides = PhysicsWorld.mover_collides_sides(Game.physics_world, mover)
+		local coll_up    = PhysicsWorld.mover_collides_up(Game.physics_world, mover)
+		local coll_down  = PhysicsWorld.mover_collides_down(Game.physics_world, mover)
+
+		local camera_transform = SceneGraph.instance(Game.scene_graph, Game.camera:unit())
+		local camera_forward = Matrix4x4.y(SceneGraph.local_pose(Game.scene_graph, camera_transform))
+		local camera_right = Matrix4x4.x(SceneGraph.local_pose(Game.scene_graph, camera_transform))
+		local delta = Vector3(camera_forward.x, camera_forward.y, 0) * dy
+			+ Vector3(camera_right.x, camera_right.y, 0) * dx
+
+		if Vector3.length(delta) > 0.0001 then
+			Vector3.normalize(delta)
+		end
+
+		local jump_pressed = Keyboard.pressed(Keyboard.button_id("space"))
+		local run_pressed = Keyboard.button(Keyboard.button_id("shift_left"))
+
+		local speed = Game.walk_speed
+		if run_pressed ~= 0 then
+			speed = speed * Game.run_multiplier
+		end
+		delta = delta * speed
+
+		if jump_pressed and coll_down then
+			Game.vertical_speed = Game.gravity * 0.25
+		else
+			if coll_down then
+				Game.vertical_speed = -0.1
+			else
+				Game.vertical_speed = math.max(-50, Game.vertical_speed - Game.gravity * dt)
+			end
+		end
+
+		delta.z = Game.vertical_speed
+		PhysicsWorld.mover_move(Game.physics_world, mover, delta*(1/120))
+
+		-- Copy mover position to character position.
+		local mover_pos = PhysicsWorld.mover_position(Game.physics_world, mover)
+		local character_transform = SceneGraph.instance(Game.scene_graph, Game.character_unit)
+		assert(character_transform)
+		SceneGraph.set_local_position(Game.scene_graph, character_transform, mover_pos)
+	else
+		Game.camera:move(dt, dx, dy)
 	end
 
+	-- Update camera.
+	local cursor_delta = Mouse.axis(Mouse.axis_id("cursor_delta"))
+	Game.camera:rotate(dt, cursor_delta.x, cursor_delta.y)
+
 	-- Toggle help.
 	if Keyboard.pressed(Keyboard.button_id("f1")) then
 		GameBase.show_help = not GameBase.show_help
 	end
 
+	-- Draw 3D labels.
+	local camera_view = Matrix4x4.y(camera_world)
+	local camera_right = Matrix4x4.x(camera_world)
+
+	for k, v in pairs({ label_slopes = "Slopes", label_moving_platforms = "Moving Platforms", label_trigger = "Trigger", label_raycast = "Raycast" }) do
+		local label_unit = World.unit_by_name(GameBase.world, k)
+
+		if label_unit then
+			local label_transform = SceneGraph.instance(Game.scene_graph, label_unit)
+			local label_position = SceneGraph.local_position(Game.scene_graph, label_transform)
+			local font_resource = "core/game/hud/debug"
+			local font_size = 1.5
+			local label_extents = Gui.text_extents(Game.world_gui, font_size, v, font_resource)
+			local label_pose = Matrix4x4.from_axes(camera_right
+				, Vector3(0, 0, 1)
+				, camera_view
+				, label_position - camera_right * label_extents.x * 0.5
+				)
+
+			Gui.text_3d(Game.world_gui, label_pose, Vector3.zero(), font_size, v, font_resource)
+		end
+	end
+
+	-- Draw crosshair.
+	local win_w, win_h = Device.resolution()
+	Gui.rect(GameBase.screen_gui, Vector2(win_w/2, win_h/2), Vector2(4, 4), Color4(255, 0, 255, 255))
+
 	GameBase.draw_help({{ key = "f1", desc = "Toggle help" },
-		{ key = "w/a/s/d", desc = "Move" },
+		{ key = "w/a/s/d", desc = "Walk" },
+		{ key = "shift", desc = "Run" },
+		{ key = "space", desc = "Jump" },
+		{ key = "e", desc = "Interact" },
 		{ key = "left click", desc = "Shoot" },
-		{ key = "space", desc = "Toggle mouse lock" },
 		{ key = "z", desc = "Toggle physics debug" },
 		{ key = "x", desc = "Toggle graphics debug" },
 		{ key = "esc", desc = "Quit" }}
 		, "Crown Physics Sample"
 		)
 
-	-- Update camera.
-	local dx = Keyboard.button(Keyboard.button_id("d")) - Keyboard.button(Keyboard.button_id("a"))
-	local dy = Keyboard.button(Keyboard.button_id("w")) - Keyboard.button(Keyboard.button_id("s"))
-	local cursor_delta = Mouse.axis(Mouse.axis_id("cursor_delta"))
-	Game.camera:rotate(dt, cursor_delta.x, cursor_delta.y)
-	Game.camera:move(dt, dx, dy)
+	-- Toggle debug drawing.
+	if Keyboard.released(Keyboard.button_id("z")) then
+		Game.debug_physics = not Game.debug_physics
+		PhysicsWorld.enable_debug_drawing(Game.physics_world, Game.debug_physics)
+	end
+
+	if Keyboard.released(Keyboard.button_id("x")) then
+		Game.debug_graphics = not Game.debug_graphics
+		RenderWorld.enable_debug_drawing(Game.render_world, Game.debug_graphics)
+	end
 end
 
 function Game.render(dt)

BIN
samples/01-physics/sfx/ambient.ogg


+ 3 - 0
samples/01-physics/sfx/ambient.sound

@@ -0,0 +1,3 @@
+_guid = "eb4bb59c-4884-4109-a66a-13924257f68f"
+_type = "sound"
+source = "sfx/ambient.ogg"

+ 3 - 0
samples/01-physics/sfx/bounce.sound

@@ -0,0 +1,3 @@
+_guid = "8b6bc806-dcfb-418c-bb08-212be0b5f87e"
+_type = "sound"
+source = "sfx/bounce.wav"

BIN
samples/01-physics/sfx/bounce.wav


+ 3 - 0
samples/01-physics/sfx/shoot.sound

@@ -0,0 +1,3 @@
+_guid = "c629e269-329a-4f3b-a2b7-7fe6c952d8fc"
+_type = "sound"
+source = "sfx/shoot.wav"

BIN
samples/01-physics/sfx/shoot.wav


+ 50 - 0
samples/01-physics/units/bullet/bullet.lua

@@ -0,0 +1,50 @@
+-- Note: the following table must be global and uniquely named.
+Bullet = Bullet or {
+	data = {}
+}
+
+local data = Bullet.data
+
+-- Called after units are spawned into a world.
+function Bullet.spawned(world, units)
+	if data[world] == nil then
+		data[world] = {}
+	end
+
+	local world_data = data[world]
+
+	for _, unit in pairs(units) do
+		-- Store instance-specific data.
+		if world_data[unit] == nil then
+			world_data[unit] = { }
+		end
+	end
+end
+
+-- Called once per frame.
+function Bullet.update(world, dt)
+	local world_data = data[world]
+
+	for unit, unit_data in pairs(world_data) do
+		-- Update unit.
+	end
+end
+
+-- Called before units are unspawned from a world.
+function Bullet.unspawned(world, units)
+	local world_data = data[world]
+
+	-- Cleanup.
+	for _, unit in pairs(units) do
+		if world_data[unit] then
+			world_data[unit] = nil
+		end
+	end
+end
+
+function Bullet.collision_begin(world, unit, other_unit, actor, other_actor, position, normal, distance)
+	World.play_sound(world, "sfx/bounce", false, 1.0, 200, position)
+end
+
+return Bullet
+

+ 57 - 0
samples/01-physics/units/bullet/bullet.material

@@ -0,0 +1,57 @@
+_guid = "5e2ad4c8-a4f1-490c-8036-a6ccb61aec9c"
+_type = "material"
+shader = "mesh"
+uniforms = {
+	u_albedo = {
+		type = "vector3"
+		value = [
+			1
+			1
+			0
+		]
+	}
+	u_emission_color = {
+		type = "vector3"
+		value = [
+			1
+			1
+			0
+		]
+	}
+	u_emission_intensity = {
+		type = "float"
+		value = 5
+	}
+	u_metallic = {
+		type = "float"
+		value = 0
+	}
+	u_roughness = {
+		type = "float"
+		value = 1
+	}
+	u_use_albedo_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_ao_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_emission_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_metallic_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_normal_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_roughness_map = {
+		type = "float"
+		value = 0
+	}
+}

+ 50 - 0
samples/01-physics/units/bullet/bullet.unit

@@ -0,0 +1,50 @@
+_guid = "78a2e0f8-7bb1-4b26-bef4-7c25b8d77b49"
+_type = "unit"
+components = [
+	{
+		_guid = "4e584507-dada-4c33-8e93-3d030bc7903e"
+		_type = "script"
+		data = {
+			script_resource = "units/bullet/bullet"
+		}
+	}
+]
+editor = {
+	name = "sphere2"
+}
+modified_components = {
+	#8972a214-327e-4396-b01e-45701189e8c9 = {
+		data = {
+			position = [
+				2.7662143700000001
+				-24.903016999999998
+				0.5
+			]
+			rotation = [
+				0
+				0
+				0
+				1
+			]
+			scale = [
+				0.25
+				0.25
+				0.25
+			]
+		}
+	}
+	#b90d4427-bc08-4d40-aaf5-9d0eb80be391 = {
+		data = {
+			class = "dynamic"
+			mass = 0.25
+			material = "bullet"
+			collision_filter = "bullet"
+		}
+	}
+	#ce881722-b0da-41ea-b29b-b26b85cf61b5 = {
+		data = {
+			material = "units/bullet/bullet"
+		}
+	}
+}
+prefab = "core/units/primitives/sphere"

+ 0 - 24
samples/01-physics/units/cube.mesh

@@ -1,24 +0,0 @@
-geometries = {
-    "Cube" = {
-        position = [ 1.000000 1.000000 -1.000000 1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 0.999999 1.000000 0.999999 -1.000001 1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 ]
-        normal = [ -0.000000 -0.000000 -1.000000 0.000000 0.000000 1.000000 1.000000 0.000000 -0.000000 -0.000000 -1.000000 -0.000000 -1.000000 0.000000 -0.000000 0.000000 1.000000 0.000000 1.000000 -0.000001 0.000000 ]
-        texcoord = [ 1.000000 1.000000 0.000000 0.000000 0.000000 1.000000 1.000000 0.000000 ]
-        tangent = [ 0.000000 -1.000000 0.000000 -1.000000 0.000000 0.000000 0.000000 -0.000000 1.000000 -0.000000 0.000000 -1.000000 ]
-        bitangent = [ -1.000000 -0.000000 -0.000000 -0.000000 -1.000000 0.000000 0.000000 1.000000 0.000000 -0.000001 -1.000000 -0.000000 ]
-        indices = {
-            size = 36
-            data = [
-                [ 1 3 0 7 5 4 4 1 0 5 2 1 2 7 3 0 7 4 1 2 3 7 6 5 4 5 1 5 6 2 2 6 7 0 3 7 ]
-                [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 0 0 0 1 1 1 6 6 6 3 3 3 4 4 4 5 5 5 ]
-                [ 0 1 2 0 1 2 0 1 2 0 1 2 2 3 1 0 1 2 0 3 1 0 3 1 0 3 1 0 3 1 2 0 3 0 3 1 ]
-                [ 0 0 0 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 0 0 0 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 ]
-                [ 0 0 0 1 1 1 1 1 1 0 0 0 2 2 2 0 0 0 0 0 0 1 1 1 3 3 3 0 0 0 2 2 2 0 0 0 ]
-            ]
-        }
-    }
-}
-nodes = {
-	"Cube" = {
-		matrix_local = [ 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 ]
-	}
-}

+ 0 - 60
samples/01-physics/units/cube.unit

@@ -1,60 +0,0 @@
-_guid = "92611e74-8e8a-46c6-b505-f587ef089cbf"
-_type = "unit"
-components = [
-	{
-		_guid = "171eb351-61a4-4f6d-a069-f52ca7b0dc55"
-		_type = "actor"
-		data = {
-			class = "dynamic"
-			collision_filter = "default"
-			mass = 10
-			material = "default"
-		}
-		type = "actor"
-	}
-	{
-		_guid = "49576e7e-2eed-42a7-8ce1-785f519d9655"
-		_type = "mesh_renderer"
-		data = {
-			geometry_name = "Cube"
-			material = "units/grid"
-			mesh_resource = "units/cube"
-			visible = true
-		}
-		type = "mesh_renderer"
-	}
-	{
-		_guid = "a122f56c-be01-46da-9459-c84bc7381221"
-		_type = "collider"
-		data = {
-			material = "default"
-			name = "Cube"
-			scene = "units/cube"
-			shape = "box"
-		}
-		type = "collider"
-	}
-	{
-		_guid = "f56420ad-7f9c-4cca-aca5-350f366e0dc0"
-		_type = "transform"
-		data = {
-			position = [
-				0
-				0
-				0
-			]
-			rotation = [
-				0
-				0
-				0
-				1
-			]
-			scale = [
-				1
-				1
-				1
-			]
-		}
-		type = "transform"
-	}
-]

+ 57 - 0
samples/01-physics/units/door_button/door_button.material

@@ -0,0 +1,57 @@
+_guid = "ce279932-0f3f-46f0-a9ef-7257f77460db"
+_type = "material"
+shader = "mesh"
+uniforms = {
+	u_albedo = {
+		type = "vector3"
+		value = [
+			0
+			1
+			0
+		]
+	}
+	u_emission_color = {
+		type = "vector3"
+		value = [
+			0
+			0
+			0
+		]
+	}
+	u_emission_intensity = {
+		type = "float"
+		value = 1
+	}
+	u_metallic = {
+		type = "float"
+		value = 0
+	}
+	u_roughness = {
+		type = "float"
+		value = 1
+	}
+	u_use_albedo_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_ao_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_emission_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_metallic_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_normal_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_roughness_map = {
+		type = "float"
+		value = 0
+	}
+}

+ 14 - 0
samples/01-physics/units/grid.material

@@ -57,4 +57,18 @@ uniforms = {
 		type = "float"
 		value = 0
 	}
+	u_uv_scale = {
+		type = "vector2"
+		value = [
+			300
+			300
+		]
+	}
+	u_uv_offset = {
+		type = "vector2"
+		value = [
+			0
+			0
+		]
+	}
 }

+ 1 - 0
samples/01-physics/units/grid.texture

@@ -11,6 +11,7 @@ output = {
 	}
 	linux = {
 		format = "BC1"
+		normal_map = false
 	}
 	windows = {
 		format = "BC1"

+ 59 - 0
samples/01-physics/units/moving_platform/moving_platform.lua

@@ -0,0 +1,59 @@
+-- Note: the following table must be global and uniquely named.
+UnitsMovingPlatformMovingPlatform = UnitsMovingPlatformMovingPlatform or {
+	data = {}
+}
+
+local data = UnitsMovingPlatformMovingPlatform.data
+
+function UnitsMovingPlatformMovingPlatform.spawned(world, units)
+	if data[world] == nil then
+		data[world] = {}
+	end
+
+	local world_data = data[world]
+
+	for _, unit in pairs(units) do
+		-- Store instance-specific data.
+		if world_data[unit] == nil then
+			world_data[unit] = { zmin = 0.75, zmax = 7.75, zvel = 2, twait = 1.0, tcur = 0 }
+		end
+	end
+end
+
+function UnitsMovingPlatformMovingPlatform.update(world, dt)
+	local world_data = data[world]
+	local scene_graph = World.scene_graph(world)
+
+	-- Moving platform.
+	for unit, unit_data in pairs(world_data) do
+		local platform = SceneGraph.instance(scene_graph, unit)
+		local platform_pos = SceneGraph.local_position(scene_graph, platform)
+
+		if unit_data.tcur == 0 and (platform_pos.z >= unit_data.zmax or platform_pos.z <= unit_data.zmin) then
+			unit_data.zvel = -unit_data.zvel
+			unit_data.tcur = unit_data.twait
+		end
+
+		if unit_data.tcur <= 0 then
+			local new_position = platform_pos + Vector3(0, 0, unit_data.zvel) * dt
+			new_position.z = math.max(unit_data.zmin, math.min(unit_data.zmax, new_position.z))
+			SceneGraph.set_local_position(scene_graph, platform, new_position)
+			unit_data.tcur = 0
+		else
+			unit_data.tcur = unit_data.tcur - dt
+		end
+	end
+end
+
+function UnitsMovingPlatformMovingPlatform.unspawned(world, units)
+	local world_data = data[world]
+
+	-- Cleanup.
+	for _, unit in pairs(units) do
+		if world_data[unit] then
+			world_data[unit] = nil
+		end
+	end
+end
+
+return UnitsMovingPlatformMovingPlatform

+ 57 - 0
samples/01-physics/units/moving_platform/moving_platform.material

@@ -0,0 +1,57 @@
+_guid = "64e7015c-49c6-45fe-a502-68d34b220fa6"
+_type = "material"
+shader = "mesh"
+uniforms = {
+	u_albedo = {
+		type = "vector3"
+		value = [
+			1
+			1
+			0
+		]
+	}
+	u_emission_color = {
+		type = "vector3"
+		value = [
+			0
+			0
+			0
+		]
+	}
+	u_emission_intensity = {
+		type = "float"
+		value = 1
+	}
+	u_metallic = {
+		type = "float"
+		value = 0
+	}
+	u_roughness = {
+		type = "float"
+		value = 1
+	}
+	u_use_albedo_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_ao_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_emission_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_metallic_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_normal_map = {
+		type = "float"
+		value = 0
+	}
+	u_use_roughness_map = {
+		type = "float"
+		value = 0
+	}
+}

+ 47 - 0
samples/01-physics/units/moving_platform/moving_platform.unit

@@ -0,0 +1,47 @@
+_guid = "04558684-34ba-4391-b13d-e146344e102c"
+_type = "unit"
+components = [
+	{
+		_guid = "a2840e1b-102c-4d70-9c5b-9d8808fccc45"
+		_type = "script"
+		data = {
+			script_resource = "units/moving_platform/moving_platform"
+		}
+	}
+]
+editor = {
+	name = "moving_platform"
+}
+modified_components = {
+	#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+		data = {
+			position = [
+				-5.5794782600000001
+				-6.9317741399999999
+				2.4330945000000002
+			]
+			rotation = [
+				0
+				0
+				0
+				1
+			]
+			scale = [
+				4
+				4
+				0.5
+			]
+		}
+	}
+	#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+		data = {
+			class = "keyframed"
+		}
+	}
+	#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+		data = {
+			material = "units/moving_platform/moving_platform"
+		}
+	}
+}
+prefab = "core/units/primitives/cube"

+ 0 - 24
samples/01-physics/units/plane.mesh

@@ -1,24 +0,0 @@
-geometries = {
-    "Plane" = {
-        position = [ -256.000000 -256.000000 0.000000 256.000000 -256.000000 0.000000 -256.000000 256.000000 0.000000 256.000000 256.000000 0.000000 ]
-        normal = [ -0.000000 0.000000 1.000000 ]
-        texcoord = [ 128.474411 128.474403 -127.474403 -127.474411 -127.474388 128.474403 128.474411 -127.474411 ]
-        tangent = [ 1.000000 0.000000 0.000000 ]
-        bitangent = [ 0.000000 1.000000 0.000000 ]
-        indices = {
-            size = 6
-            data = [
-                [ 1 2 0 1 3 2 ]
-                [ 0 0 0 0 0 0 ]
-                [ 0 1 2 0 3 1 ]
-                [ 0 0 0 0 0 0 ]
-                [ 0 0 0 0 0 0 ]
-            ]
-        }
-    }
-}
-nodes = {
-	"Plane" = {
-		matrix_local = [ 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 ]
-	}
-}

+ 0 - 60
samples/01-physics/units/plane.unit

@@ -1,60 +0,0 @@
-_guid = "57565326-a8a1-4c4b-b85d-6847d78e1bbd"
-_type = "unit"
-components = [
-	{
-		_guid = "114ece38-a553-4a49-8fa7-07b49e061a66"
-		_type = "collider"
-		data = {
-			material = "default"
-			name = "Plane"
-			scene = "units/plane"
-			shape = "convex_hull"
-		}
-		type = "collider"
-	}
-	{
-		_guid = "445eb72e-e80d-4549-95db-2438f3401168"
-		_type = "mesh_renderer"
-		data = {
-			geometry_name = "Plane"
-			material = "units/grid"
-			mesh_resource = "units/plane"
-			visible = true
-		}
-		type = "mesh_renderer"
-	}
-	{
-		_guid = "52cec360-697d-4493-a369-1674bcb1d236"
-		_type = "actor"
-		data = {
-			class = "static"
-			collision_filter = "default"
-			mass = 10
-			material = "default"
-		}
-		type = "actor"
-	}
-	{
-		_guid = "805e9323-578b-4d22-8414-b15b1a5ff7bc"
-		_type = "transform"
-		data = {
-			position = [
-				0
-				0
-				0
-			]
-			rotation = [
-				0
-				0
-				0
-				1
-			]
-			scale = [
-				1
-				1
-				1
-			]
-		}
-		type = "transform"
-	}
-]

+ 0 - 24
samples/01-physics/units/ramp.mesh

@@ -1,24 +0,0 @@
-geometries = {
-    "Cube" = {
-        position = [ -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 5.000000 -1.000000 1.000000 -1.000000 -1.000000 1.000000 5.000000 1.000000 -1.000000 -1.000000 1.000000 -1.000000 0.021450 1.000000 1.000000 -1.000000 1.000000 1.000000 0.021450 ]
-        normal = [ -1.000000 0.000000 0.000000 -0.000000 1.000000 0.000000 1.000000 0.000000 0.000000 0.000000 -1.000000 0.000000 0.000000 0.000000 -1.000000 0.927924 0.000000 0.372769 ]
-        texcoord = [ 1.000000 1.000000 0.000000 0.000000 0.000000 1.000000 1.000000 0.000000 ]
-        tangent = [ 0.000000 1.000000 0.000000 0.744310 0.000000 -0.667835 0.654175 0.000000 -0.756344 0.372769 0.000000 -0.927924 0.000000 -1.000000 0.000000 -0.744310 0.000000 0.667835 -0.654175 0.000000 0.756344 -1.000000 0.000000 0.000000 1.000000 0.000000 0.000000 -0.372769 0.000000 0.927924 ]
-        bitangent = [ 0.000000 0.000000 -1.000000 -0.667835 0.000000 -0.744310 -0.756344 0.000000 -0.654175 -0.927924 0.000000 -0.372769 1.000000 -0.000000 0.000000 -0.372769 0.000000 0.927924 ]
-        indices = {
-            size = 36
-            data = [
-                [ 3 0 1 7 2 3 5 6 7 5 0 4 2 4 0 7 1 5 3 2 0 7 6 2 5 4 6 5 1 0 2 6 4 7 3 1 ]
-                [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 ]
-                [ 0 1 2 0 1 2 0 1 2 2 3 1 0 1 2 0 1 2 0 3 1 0 3 1 0 3 1 2 0 3 0 3 1 0 3 1 ]
-                [ 0 0 0 1 2 3 4 4 4 5 6 7 0 0 0 0 0 0 0 0 0 1 8 2 4 4 4 5 9 6 0 0 0 0 0 0 ]
-                [ 0 0 0 1 2 3 0 0 0 1 2 0 4 4 4 5 5 5 0 0 0 1 0 2 0 0 0 1 3 2 4 4 4 5 5 5 ]
-            ]
-        }
-    }
-}
-nodes = {
-	"Cube" = {
-		matrix_local = [ 8.000000 0.000000 0.000000 0.000000 0.000000 8.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 ]
-	}
-}

+ 0 - 60
samples/01-physics/units/ramp.unit

@@ -1,60 +0,0 @@
-_guid = "fc541009-f6bf-4689-84cb-2f976c9ff38a"
-_type = "unit"
-components = [
-	{
-		_guid = "1089a8ef-c51f-417d-9160-3716b5b441d7"
-		_type = "transform"
-		data = {
-			position = [
-				0
-				0
-				0
-			]
-			rotation = [
-				0
-				0
-				0
-				1
-			]
-			scale = [
-				8
-				8
-				1
-			]
-		}
-		type = "transform"
-	}
-	{
-		_guid = "3d3bbab0-2fca-4932-a38f-41e7cb339216"
-		_type = "actor"
-		data = {
-			class = "static"
-			collision_filter = "default"
-			mass = 10
-			material = "default"
-		}
-		type = "actor"
-	}
-	{
-		_guid = "d79ef8c9-b2c1-4a67-adc9-07154f7352d7"
-		_type = "collider"
-		data = {
-			material = "default"
-			name = "Cube"
-			scene = "units/ramp"
-			shape = "convex_hull"
-		}
-		type = "collider"
-	}
-	{
-		_guid = "e8d9961f-d868-4b26-a4d7-7d2891cead99"
-		_type = "mesh_renderer"
-		data = {
-			geometry_name = "Cube"
-			material = "units/grid"
-			mesh_resource = "units/ramp"
-			visible = true
-		}
-		type = "mesh_renderer"
-	}
-]

+ 28 - 0
samples/01-physics/units/sliding_door/sliding_door.unit

@@ -0,0 +1,28 @@
+_guid = "ab86bf27-a9d2-4c62-8d03-8035ea845071"
+_type = "unit"
+editor = {
+	name = "sliding_door"
+}
+modified_components = {
+	#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+		data = {
+			position = [
+				6
+				33
+				2.5
+			]
+			rotation = [
+				0
+				0
+				0
+				1
+			]
+			scale = [
+				2.5
+				0.5
+				4
+			]
+		}
+	}
+}
+prefab = "core/units/primitives/cube"

+ 74 - 0
samples/01-physics/units/sliding_door/sliding_door_trigger.lua

@@ -0,0 +1,74 @@
+-- Note: the following table must be global and uniquely named.
+SlidingDoorTrigger = SlidingDoorTrigger or {
+	data = {}
+}
+
+local data = SlidingDoorTrigger.data
+
+-- Called after units are spawned into a world.
+function SlidingDoorTrigger.spawned(world, units)
+	if data[world] == nil then
+		data[world] = {}
+	end
+
+	local world_data = data[world]
+
+	for _, unit in pairs(units) do
+		-- Store instance-specific data.
+		if world_data[unit] == nil then
+			world_data[unit] = {}
+		end
+	end
+end
+
+-- Called once per frame.
+function SlidingDoorTrigger.update(world, dt)
+	local world_data = data[world]
+
+	for unit, unit_data in pairs(world_data) do
+		-- Update unit.
+	end
+end
+
+-- Called before units are unspawned from a world.
+function SlidingDoorTrigger.unspawned(world, units)
+	local world_data = data[world]
+
+	-- Cleanup.
+	for _, unit in pairs(units) do
+		if world_data[unit] then
+			world_data[unit] = nil
+		end
+	end
+end
+
+function SlidingDoorTrigger.unspawned(world, units)
+end
+
+function SlidingDoorTrigger.trigger_enter(world, trigger_unit, other_unit)
+	local player = World.unit_by_name(world, "character")
+	local door = World.unit_by_name(world, "trigger_door")
+
+	if door and player and other_unit == player then
+		local scene_graph = World.scene_graph(world)
+		local door_transform = SceneGraph.instance(scene_graph, door)
+		local door_position = SceneGraph.local_position(scene_graph, door_transform)
+		local new_door_position = door_position - Vector3(2.3, 0, 0)
+		SceneGraph.set_local_position(scene_graph, door_transform, new_door_position)
+	end
+end
+
+function SlidingDoorTrigger.trigger_leave(world, trigger_unit, other_unit)
+	local player = World.unit_by_name(world, "character")
+	local door = World.unit_by_name(world, "trigger_door")
+
+	if door and player and other_unit == player then
+		local scene_graph = World.scene_graph(world)
+		local door_transform = SceneGraph.instance(scene_graph, door)
+		local door_position = SceneGraph.local_position(scene_graph, door_transform)
+		local new_door_position = door_position + Vector3(2.3, 0, 0)
+		SceneGraph.set_local_position(scene_graph, door_transform, new_door_position)
+	end
+end
+
+return SlidingDoorTrigger

+ 38 - 0
samples/01-physics/units/sliding_door/sliding_door_trigger.unit

@@ -0,0 +1,38 @@
+_guid = "474de287-9969-4c0b-9926-a7da11adcd25"
+_type = "unit"
+editor = {
+	name = "sliding_door_trigger"
+}
+modified_components = {
+	#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+		data = {
+			position = [
+				6
+				33
+				2
+			]
+			rotation = [
+				0
+				0
+				0
+				1
+			]
+			scale = [
+				2.5
+				4
+				3
+			]
+		}
+	}
+	#49753fff-34ea-4aff-8bcf-5116f1c1519a = {
+		data = {
+			visible = false
+		}
+	}
+	#b15082c5-3aaf-4c9a-8925-e5c958d49171 = {
+		data = {
+			class = "trigger"
+		}
+	}
+}
+prefab = "core/units/primitives/cube"

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 2
samples/01-physics/units/sphere.mesh


+ 0 - 60
samples/01-physics/units/sphere.unit

@@ -1,60 +0,0 @@
-_guid = "388fafa2-e728-4e27-a5de-41e61019f2b6"
-_type = "unit"
-components = [
-	{
-		_guid = "637b5db3-1074-4852-a9f2-59c2eea2c2a5"
-		_type = "transform"
-		data = {
-			position = [
-				0
-				0
-				0
-			]
-			rotation = [
-				0
-				0
-				0
-				1
-			]
-			scale = [
-				1
-				1
-				1
-			]
-		}
-		type = "transform"
-	}
-	{
-		_guid = "7b9da2e3-47ca-40fd-a31b-cb6cbe8fba57"
-		_type = "mesh_renderer"
-		data = {
-			geometry_name = "Sphere"
-			material = "units/grid"
-			mesh_resource = "units/sphere"
-			visible = true
-		}
-		type = "mesh_renderer"
-	}
-	{
-		_guid = "9e94f3a3-4113-4af8-bc64-c78c2e82bcd4"
-		_type = "collider"
-		data = {
-			material = "default"
-			name = "Sphere"
-			scene = "units/sphere"
-			shape = "sphere"
-		}
-		type = "collider"
-	}
-	{
-		_guid = "cff93999-e1aa-4b23-bc10-d2897e061c26"
-		_type = "actor"
-		data = {
-			class = "dynamic"
-			collision_filter = "default"
-			mass = 15
-			material = "default"
-		}
-		type = "actor"
-	}
-]

+ 28 - 0
samples/01-physics/units/wall/wall.unit

@@ -0,0 +1,28 @@
+_guid = "2814e656-0912-4890-a47f-42033dbc6c2b"
+_type = "unit"
+editor = {
+	name = "wall"
+}
+modified_components = {
+	#23dbf108-db64-4ca2-9647-8c639ee039ad = {
+		data = {
+			position = [
+				0
+				50
+				5
+			]
+			rotation = [
+				0
+				0
+				0
+				1
+			]
+			scale = [
+				100
+				1
+				10
+			]
+		}
+	}
+}
+prefab = "core/units/primitives/cube"

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно