Skip to content

Commit

Permalink
Particles for body slam (#224)
Browse files Browse the repository at this point in the history
* Reset player animation speed when in a dialog

* Added body slam partitions

* Made effect grayer

* Random scale for each particle

* Fixed bug where sometimes particles wouldn't trigger
  • Loading branch information
telmotrooper authored Jul 12, 2023
1 parent 3dc16cf commit 030c6c7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
13 changes: 11 additions & 2 deletions entities/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ func _physics_process(delta: float) -> void:
velocity.x = direction.x * speed
velocity.z = direction.z * speed

if is_on_floor():
if is_body_slamming and is_on_floor():
$BodySlamParticles.restart()
$BodySlamParticles.emitting = true
is_body_slamming = false

if not is_jumping and Input.is_action_pressed("jump"): # Single jump.
Expand All @@ -143,7 +145,7 @@ func _physics_process(delta: float) -> void:
is_double_jumping = false

var safe_position_condition = (
$RayCasts/RayCast.is_colliding() and
$RayCasts/RayCast.get_collider() and $RayCasts/RayCast.is_colliding() and
not $RayCasts/RayCast.get_collider().get_collision_layer_value(GameState.collision_layers["Water"]) and
not $RayCasts/RayCast.get_collider().is_in_group("breakable_floor") and
$RayCasts/RayCast.get_collider() == $RayCasts/RayCast2.get_collider() and
Expand Down Expand Up @@ -274,3 +276,10 @@ func update_minimap() -> void:
minimap_pivot.rotation = $CameraPivot/Horizontal.rotation.y
var player_cursor_pivot = GameState.UserInterface.get_node("%PlayerCursorPivot")
player_cursor_pivot.rotation = $CameraPivot/Horizontal.rotation.y + $ModelPivot.rotation.y * -1

func set_cutscene_mode(enabled: bool) -> void:
if enabled:
GameState.Player.paused = true
$AnimationPlayer.speed_scale = 1.0
else:
GameState.Player.paused = false
30 changes: 29 additions & 1 deletion entities/player/player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=24 format=3 uid="uid://goxaxv03ucgy"]
[gd_scene load_steps=27 format=3 uid="uid://goxaxv03ucgy"]

[ext_resource type="Script" path="res://entities/player/player.gd" id="2"]
[ext_resource type="Script" path="res://entities/player/camera.gd" id="3"]
Expand Down Expand Up @@ -254,6 +254,24 @@ _data = {
"shrink": SubResource("7")
}

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_dyt2w"]
emission_shape = 6
emission_ring_axis = Vector3(0, 1, 0)
emission_ring_height = 1.0
emission_ring_radius = 3.0
emission_ring_inner_radius = 1.5
radial_accel_min = 10.0
radial_accel_max = 10.0
scale_min = 0.25

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8u7bp"]
transparency = 1
vertex_color_use_as_albedo = true
albedo_color = Color(0.901961, 0.901961, 0.901961, 0.588235)

[sub_resource type="SphereMesh" id="SphereMesh_r06iu"]
material = SubResource("StandardMaterial3D_8u7bp")

[node name="Player" type="CharacterBody3D" groups=["players"]]
collision_mask = 525006
script = ExtResource("2")
Expand Down Expand Up @@ -365,6 +383,16 @@ target_position = Vector3(0, -3, 0)
collision_mask = 36
collide_with_areas = true

[node name="BodySlamParticles" type="GPUParticles3D" parent="."]
emitting = false
amount = 60
lifetime = 0.5
one_shot = true
explosiveness = 1.0
randomness = 1.0
process_material = SubResource("ParticleProcessMaterial_dyt2w")
draw_pass_1 = SubResource("SphereMesh_r06iu")

[connection signal="body_entered" from="EnemyDetector" to="." method="_on_EnemyDetector_body_entered"]
[connection signal="timeout" from="DashDurationTimer" to="." method="_on_DashDurationTimer_timeout"]

Expand Down
4 changes: 2 additions & 2 deletions ui/dialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func set_text(text) -> void:
text_to_write = text

func open_dialog() -> void:
GameState.Player.paused = true
GameState.Player.set_cutscene_mode(true)
GameState.minimap.hide()
show()
var tween = create_tween()
Expand Down Expand Up @@ -50,6 +50,6 @@ func close_dialog() -> void:
%DialogText.text = ""
hide()
GameState.minimap.show()
GameState.Player.paused = false
GameState.Player.set_cutscene_mode(false)
emit_signal("finished")
)

0 comments on commit 030c6c7

Please sign in to comment.