From be26131b395a814b1ad5d5328af6c245a3a44b1c Mon Sep 17 00:00:00 2001 From: derek Date: Mon, 16 Jun 2025 15:21:31 -0500 Subject: [PATCH] added ground pound --- assets/player.tscn | 4 +++- scripts/player_ground_pound.gd | 11 +++++++++++ scripts/player_ground_pound.gd.uid | 1 + scripts/player_jumping.gd | 9 +++++++-- scripts/player_on_foot.gd | 5 +---- 5 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 scripts/player_ground_pound.gd create mode 100644 scripts/player_ground_pound.gd.uid diff --git a/assets/player.tscn b/assets/player.tscn index 28414c2..ddd266e 100644 --- a/assets/player.tscn +++ b/assets/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=42 format=3 uid="uid://drwae3loscbw7"] +[gd_scene load_steps=43 format=3 uid="uid://drwae3loscbw7"] [ext_resource type="Script" uid="uid://bieeh1iro4ji1" path="res://scripts/player.gd" id="1_x7wms"] [ext_resource type="Script" uid="uid://linvnr16djav" path="res://scripts/PlayerStateMachine.gd" id="2_1npgd"] @@ -10,6 +10,7 @@ [ext_resource type="Script" uid="uid://clyi3lxv4xt4g" path="res://scripts/player_jumping.gd" id="5_m0ick"] [ext_resource type="PackedScene" uid="uid://br882tlh3cfwu" path="res://hud.tscn" id="5_yenaw"] [ext_resource type="Script" uid="uid://bgj2bqb5dys41" path="res://scripts/player_wall_running.gd" id="6_1npgd"] +[ext_resource type="Script" uid="uid://boyl3qkg4j4vc" path="res://scripts/player_ground_pound.gd" id="7_2asft"] [ext_resource type="AudioStream" uid="uid://bki17g7j4kqn4" path="res://assets/Audio/PickupSound Mixdown 3.wav" id="8_dwqsx"] [ext_resource type="Shader" uid="uid://djbvmc8hurccm" path="res://assets/Shaders/speedlines.gdshader" id="10_5hu7c"] [ext_resource type="AudioStream" uid="uid://dyd272r7n2ecd" path="res://assets/Audio/footsteps-shoes-jump-land-beach-sand-SBA-300118001.wav" id="10_tn0pn"] @@ -162,6 +163,7 @@ move_speed = 15.0 move_transition_speed = 15.0 [node name="Ground Pound" type="Node" parent="States"] +script = ExtResource("7_2asft") [node name="Knocked" type="Node" parent="States"] diff --git a/scripts/player_ground_pound.gd b/scripts/player_ground_pound.gd new file mode 100644 index 0000000..9cdaaef --- /dev/null +++ b/scripts/player_ground_pound.gd @@ -0,0 +1,11 @@ +extends PlayerState +class_name PlayerGroundPound + +@export var ground_pound_velocity = -35 + +func Enter(): + character.velocity += Vector3(0,ground_pound_velocity,0) + +func Physics_Update(delta): + if character.is_on_floor(): + Transitioned.emit(self, "crouched") diff --git a/scripts/player_ground_pound.gd.uid b/scripts/player_ground_pound.gd.uid new file mode 100644 index 0000000..b9f7952 --- /dev/null +++ b/scripts/player_ground_pound.gd.uid @@ -0,0 +1 @@ +uid://boyl3qkg4j4vc diff --git a/scripts/player_jumping.gd b/scripts/player_jumping.gd index fde634b..28097aa 100644 --- a/scripts/player_jumping.gd +++ b/scripts/player_jumping.gd @@ -13,6 +13,9 @@ func Physics_Update(delta): standard_movement(delta) apply_gravity(delta) + if character.is_on_floor(): + Transitioned.emit(self,"on foot") + enable_wall_rays() if Input.is_action_just_pressed("jump") and character.jumps_remaining > 0: @@ -23,8 +26,10 @@ func Physics_Update(delta): air_dash_left -= 1 character.velocity += character.movement_input().normalized() * air_dash_amount - if character.is_on_floor(): - Transitioned.emit(self,"on foot") + if Input.is_action_just_pressed("crouch"): + Transitioned.emit(self,"ground pound") + + if can_wall_run(): start_wall_running() diff --git a/scripts/player_on_foot.gd b/scripts/player_on_foot.gd index eefa894..10f5924 100644 --- a/scripts/player_on_foot.gd +++ b/scripts/player_on_foot.gd @@ -12,10 +12,7 @@ func Physics_Update(delta): Transitioned.emit(self,"in air") if Input.is_action_just_pressed("crouch"): - if character.is_on_floor(): - Transitioned.emit(self,"crouched") - else: - character.velocity.y -= 25 + Transitioned.emit(self,"crouched") if Input.is_action_just_pressed("jump"): character.jumps_remaining -= 1