OverviewFilesCommitsIssuesDocsReleasesPeers

godot-marble_madness_demo commits / 67d9080

Added three control modes for the ball (angular velocity, linear velocity, free fly) Switched to Godot Physics Tweaked default WorldEnvironment effects
67d908011da6727272765773e2310f7dfb3e2f19
by Dresk Spidflisk <dreskspidflisk@gmail.com> · 2022-01-22T01:01:34.000Z

Changed files (10) +126 -21

assets/env/cam_env.tres +6 -0
……@@ -19,8 +19,14 @@ tonemap_exposure = 0.85
1919tonemap_white = 1.9
2020ss_reflections_enabled = true
2121ssao_enabled = true
22ssao_intensity2 = 0.0
23ssao_bias = 0.001
24ssao_light_affect = 1.0
25ssao_ao_channel_affect = 1.0
2226dof_blur_far_distance = 27.05
2327dof_blur_far_transition = 2.99
2428dof_blur_far_amount = 0.11
29glow_enabled = true
30glow_bloom = 1.0
2531adjustment_brightness = 0.7
2632adjustment_contrast = 2.29
assets/levels/level0/grid.material +0 -0
(no content changes — binary or rename)
assets/levels/level0/grid_brown.material +0 -0
(no content changes — binary or rename)
assets/levels/level0/grid_teal.material +0 -0
(no content changes — binary or rename)
assets/levels/level0/teal.material +0 -0
(no content changes — binary or rename)
levels/scenes/level_0.tscn +4 -1
……@@ -19,6 +19,9 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.178, 1.877, -3.673 )
1919[node name="player_ball" parent="." instance=ExtResource( 4 )]
2020transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.733258, 2.26544, -8.91449 )
2121
22[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
23environment = ExtResource( 9 )
24
2225[node name="player_camera" parent="." instance=ExtResource( 7 )]
2326pause_mode = 2
2427environment = ExtResource( 9 )
……@@ -29,7 +32,7 @@ player_ball = NodePath("../player_ball")
2932transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 11.446, 6.01065, -19.7949 )
3033
3134[node name="DirectionalLight" type="DirectionalLight" parent="."]
32transform = Transform( 1, -1.31134e-07, -7.57103e-08, -7.57103e-08, -0.866025, 0.5, -1.31134e-07, -0.5, -0.866025, 1.23504, 3.53473, -13.0157 )
35transform = Transform( 8.74228e-08, -0.5, -0.866025, 7.57103e-08, -0.866025, 0.5, -1, -1.09278e-07, -3.78552e-08, 1.23504, 3.53473, -13.0157 )
3336light_specular = 1.087
3437light_bake_mode = 0
3538shadow_enabled = true
player/ball/player_ball.gd +72 -17
……@@ -1,21 +1,54 @@
11extends RigidBody
22
3var rolling_force = 10
4var rolling_force_max : float = 50
3enum BallPhysicsMode {
4 FREE_FLY,
5 ENGINE_PHYSICS_ROLL,
6 ENGINE_PHYSICS_LINEAR,
7 PHYSICS_MAX
8}
9
10var rolling_force : float = 10.0
11var rolling_force_max : float = 50.0
12
13var linear_force : float = 2.0
14
15var freefly_force : float = 3.0
16
17var ball_physics_mode : int = BallPhysicsMode.ENGINE_PHYSICS_LINEAR
518var bFirstPersonCamera = false
6var bDebugPaused : bool = false
7var ballCameraOriginalOrigin : Vector3
819
920var lVelocity : Label
1021var lAngularVelocity : Label
22var lBallPhysicsMode : Label
23var sldBallFrictionSlider : Slider
1124
1225func _ready():
1326 lVelocity = get_tree().get_current_scene().get_node("DebugUI").get_node("BallVelocity_Value")
1427 lAngularVelocity = get_tree().get_current_scene().get_node("DebugUI").get_node("BallAngularVelocity_Value")
28 lBallPhysicsMode = get_tree().get_current_scene().get_node("DebugUI").get_node("BallPhysicsMode_Value")
29 sldBallFrictionSlider = get_tree().get_current_scene().get_node("DebugUI").get_node("BallFrictionSlider")
30
31 updateBallPhysicsMode()
1532
1633func _process(_delta: float) -> void:
1734 pass
1835
36func updateBallPhysicsMode() -> void:
37 if(ball_physics_mode == BallPhysicsMode.FREE_FLY):
38 lBallPhysicsMode.text = "Free Fly"
39 self.angular_velocity = Vector3(0, 0, 0)
40 self.rotation = Vector3(0, 0, 0)
41 self.linear_velocity = Vector3(0, 0, 0)
42 self.mode = RigidBody.MODE_STATIC
43 elif(ball_physics_mode == BallPhysicsMode.ENGINE_PHYSICS_ROLL):
44 lBallPhysicsMode.text = "Engine Physics (Roll)"
45 self.physics_material_override.friction = 1.0
46 self.mode = RigidBody.MODE_RIGID
47 else:
48 lBallPhysicsMode.text = "Engine Physics (Linear)"
49 self.physics_material_override.friction = 0.035
50 self.mode = RigidBody.MODE_RIGID
51
1952func checkAngularVelocity(delta : float, angVelocity : float, bAdd : bool) -> float:
2053 if bAdd:
2154 angVelocity = angVelocity + rolling_force*delta
……@@ -36,9 +69,6 @@ func _physics_process(delta: float) -> void:
3669 # else:
3770 # bFirstPersonCamera = true
3871
39 if bDebugPaused:
40 return
41
4272 #if false:
4373 # ballCamera.global_transform.origin = lerp(
4474 # ballCamera.global_transform.origin,
……@@ -48,22 +78,47 @@ func _physics_process(delta: float) -> void:
4878 # ballCamera.global_transform.origin,
4979 # global_transform.origin, 1.0
5080 # )
51
5281
82 if Input.is_action_just_pressed("ball_cycle_physics_mode"):
83 ball_physics_mode = (ball_physics_mode + 1) % BallPhysicsMode.PHYSICS_MAX
84 if(ball_physics_mode == BallPhysicsMode.FREE_FLY):
85 self.mode = RigidBody.MODE_STATIC
86 else:
87 self.mode = RigidBody.MODE_RIGID
88 updateBallPhysicsMode()
5389
54 #$FloorCheck.global_transform.origin = global_transform.origin
90
91 #if(ball_physics_mode == BallPhysicsMode.FREE_FLY):
92 # return
93
5594 if Input.is_action_pressed("ball_roll_up"):
56 # angular_velocity.x = checkAngularVelocity(delta, angular_velocity.x, false)
57 angular_velocity.x = clamp(angular_velocity.x - rolling_force*delta, rolling_force_max * -1, rolling_force_max)
95 if(ball_physics_mode == BallPhysicsMode.ENGINE_PHYSICS_ROLL):
96 angular_velocity.x = clamp(angular_velocity.x - rolling_force*delta, rolling_force_max * -1, rolling_force_max)
97 elif(ball_physics_mode == BallPhysicsMode.FREE_FLY):
98 self.translate( Vector3(0, 0, -freefly_force) * delta)
99 else:
100 linear_velocity.z -= (linear_force * delta);
58101 elif Input.is_action_pressed("ball_roll_down"):
59 # angular_velocity.x = checkAngularVelocity(delta, angular_velocity.x, true)
60 angular_velocity.x = clamp(angular_velocity.x + rolling_force*delta, rolling_force_max * -1, rolling_force_max)
102 if(ball_physics_mode == BallPhysicsMode.ENGINE_PHYSICS_ROLL):
103 angular_velocity.x = clamp(angular_velocity.x + rolling_force*delta, rolling_force_max * -1, rolling_force_max)
104 elif(ball_physics_mode == BallPhysicsMode.FREE_FLY):
105 self.translate( Vector3(0, 0, freefly_force) * delta)
106 else:
107 linear_velocity.z += (linear_force * delta);
61108 if Input.is_action_pressed("ball_roll_left"):
62 #angular_velocity.z = checkAngularVelocity(delta, angular_velocity.z, true)
63 angular_velocity.z = clamp(angular_velocity.z + rolling_force*delta, rolling_force_max * -1, rolling_force_max)
109 if(ball_physics_mode == BallPhysicsMode.ENGINE_PHYSICS_ROLL):
110 angular_velocity.z = clamp(angular_velocity.z + rolling_force*delta, rolling_force_max * -1, rolling_force_max)
111 elif(ball_physics_mode == BallPhysicsMode.FREE_FLY):
112 self.translate( Vector3(-freefly_force, 0, 0) * delta)
113 else:
114 linear_velocity.x -= (linear_force * delta);
64115 elif Input.is_action_pressed("ball_roll_right"):
65 #angular_velocity.z = checkAngularVelocity(delta, angular_velocity.z, false)
66 angular_velocity.z = clamp(angular_velocity.z - rolling_force*delta, rolling_force_max * -1, rolling_force_max)
116 if(ball_physics_mode == BallPhysicsMode.ENGINE_PHYSICS_ROLL):
117 angular_velocity.z = clamp(angular_velocity.z - rolling_force*delta, rolling_force_max * -1, rolling_force_max)
118 elif(ball_physics_mode == BallPhysicsMode.FREE_FLY):
119 self.translate( Vector3(freefly_force, 0, 0) * delta)
120 else:
121 linear_velocity.x += (linear_force * delta);
67122
68123 #if Input.is_action_just_pressed("jump") and $FloorCheck.is_colliding():
69124 # apply_impulse(Vector3(), Vector3.UP*1000)
player/ball/player_ball.tscn +2 -1
……@@ -4,6 +4,7 @@
44[ext_resource path="res://player/ball/player_ball.gd" type="Script" id=2]
55
66[sub_resource type="PhysicsMaterial" id=2]
7friction = 0.0
78rough = true
89
910[sub_resource type="SphereShape" id=1]
……@@ -22,4 +23,4 @@ shape = SubResource( 1 )
2223light_color = Color( 0, 0.717647, 1, 1 )
2324light_energy = 16.0
2425light_bake_mode = 0
25omni_range = 0.174
26omni_range = 0.175
project.godot +6 -1
……@@ -41,6 +41,11 @@ ball_roll_down={
4141"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
4242 ]
4343}
44ball_cycle_physics_mode={
45"deadzone": 0.5,
46"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
47 ]
48}
4449restart_level={
4550"deadzone": 0.5,
4651"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
……@@ -69,7 +74,7 @@ camera_zoom_out={
6974
7075[physics]
7176
723d/physics_engine="Bullet"
773d/physics_engine="GodotPhysics"
73783d/active_soft_world=false
7479
7580[rendering]
ui/debug/ball/ui_debug_ball.tscn +36 -1
……@@ -1,4 +1,6 @@
1[gd_scene format=2]
1[gd_scene load_steps=2 format=2]
2
3[sub_resource type="Theme" id=1]
24
35[node name="Control" type="Control"]
46anchor_right = 1.0
……@@ -40,3 +42,36 @@ margin_bottom = 91.0
4042__meta__ = {
4143"_edit_use_anchors_": false
4244}
45
46[node name="BallPhysicsMode" type="Label" parent="."]
47margin_left = 39.0
48margin_top = 102.0
49margin_right = 178.0
50margin_bottom = 116.0
51text = "Ball Physics Mode :"
52align = 2
53__meta__ = {
54"_edit_use_anchors_": false
55}
56
57[node name="BallPhysicsMode_Value" type="Label" parent="."]
58margin_left = 186.0
59margin_top = 102.0
60margin_right = 640.0
61margin_bottom = 116.0
62__meta__ = {
63"_edit_use_anchors_": false
64}
65
66[node name="BallFrictionSlider" type="HSlider" parent="."]
67margin_left = 1347.0
68margin_top = 55.0
69margin_right = 1595.0
70margin_bottom = 71.0
71theme = SubResource( 1 )
72max_value = 1.0
73step = 0.1
74scrollable = false
75__meta__ = {
76"_edit_use_anchors_": false
77}