fix sprites being translated down on stun anim

godot-4.3
HumanoidSandvichDispenser 2024-01-06 14:11:45 -08:00
parent 097f49487a
commit eed8588eaf
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
10 changed files with 202 additions and 54 deletions

Binary file not shown.

View File

@ -542,7 +542,7 @@ particle_flag_disable_z = true
gravity = Vector3(0, 98, 0)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_uict5"]
size = Vector2(11, 5)
size = Vector2(11, 8)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8lxmf"]
size = Vector2(16, 19)
@ -759,7 +759,6 @@ offset = Vector2(0, -8)
hframes = 17
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-0.5, -1.5)
shape = SubResource("RectangleShape2D_uict5")
[node name="Hurtbox" parent="." instance=ExtResource("7_tnve0")]
@ -770,13 +769,20 @@ Faction = 2
position = Vector2(0, -3.5)
shape = SubResource("RectangleShape2D_8lxmf")
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Items")]
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Hotbar")]
y_sort_enabled = true
script = ExtResource("8_r8ejq")
Hotbar = []
Items = []
[node name="DocLance" parent="Inventory" instance=ExtResource("24_2es2r")]
[node name="DocLance" parent="Inventory" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor") instance=ExtResource("24_2es2r")]
unique_name_in_owner = true
Hitbox = NodePath("Hitbox")
AnimationPlayer = NodePath("AnimationPlayer")
ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles")
StateMachine = NodePath("State")
Anchor = NodePath("Anchor")
HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand")
[node name="InteractionTrigger" parent="." instance=ExtResource("33_08dyq")]

View File

@ -187,7 +187,6 @@ PursueState = NodePath("../Attack")
MinTargetDistance = 24.0
PursueOnLineOfSight = true
MinLineOfSightDistance = 256.0
ShouldReturnToOriginalPosition = true
NavigationAgent = NodePath("../../NavigationAgent2D")
NPC = NodePath("../..")
@ -257,7 +256,7 @@ stream = ExtResource("15_8yg1g")
unique_name_in_owner = true
y_sort_enabled = true
use_parent_material = true
position = Vector2(-0.5, 0)
position = Vector2(-0.5, 4)
rotation = 6.28319
[node name="Node2D" type="Node2D" parent="Sprites"]
@ -270,18 +269,24 @@ offset = Vector2(0, -12)
hframes = 7
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -4)
shape = SubResource("RectangleShape2D_bfqew")
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Items")]
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Hotbar")]
y_sort_enabled = true
position = Vector2(0, -4)
script = ExtResource("17_6fh5y")
Hotbar = []
Items = []
[node name="Sword" parent="Inventory" instance=ExtResource("18_7l8tj")]
[node name="Sword" parent="Inventory" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor") instance=ExtResource("18_7l8tj")]
Hitbox = NodePath("Hitbox")
AnimationPlayer = NodePath("AnimationPlayer")
ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles")
StateMachine = NodePath("State")
Anchor = NodePath("Anchor")
HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand")
[node name="Hurtbox" parent="." instance=ExtResource("19_xol7n")]
position = Vector2(0, 4)
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2(0, -8)

View File

@ -267,7 +267,7 @@ color = Color(1, 0, 0, 1)
color_ramp = SubResource("GradientTexture1D_iyaih")
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bfqew"]
size = Vector2(8, 4)
size = Vector2(8, 8)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1gjgc"]
size = Vector2(12, 16)
@ -308,7 +308,7 @@ Character = NodePath("../..")
script = ExtResource("6_pwguk")
IdleState = NodePath("../Idle")
TimeToDash = 0.1
VelocityModifier = 4.0
VelocityModifier = 10.0
Character = NodePath("../..")
[node name="ThinkerStateMachine" type="Node" parent="." node_paths=PackedStringArray("InitialState")]
@ -317,7 +317,7 @@ InitialState = NodePath("Idle")
[node name="Attack" type="Node" parent="ThinkerStateMachine" node_paths=PackedStringArray("PassiveState", "PursueState", "NPC")]
script = ExtResource("8_n8t7f")
MaxDistanceToTarget = 128.0
MaxDistanceToTarget = 256.0
UseItemDistance = 64.0
PassiveState = NodePath("../Idle")
PursueState = NodePath("../Pursue")
@ -329,7 +329,6 @@ PursueState = NodePath("../Pursue")
MinTargetDistance = 24.0
PursueOnLineOfSight = true
MinLineOfSightDistance = 256.0
ShouldReturnToOriginalPosition = true
NavigationAgent = NodePath("../../NavigationAgent2D")
NPC = NodePath("../..")
@ -408,7 +407,7 @@ stream = ExtResource("15_w7mkq")
unique_name_in_owner = true
y_sort_enabled = true
use_parent_material = true
position = Vector2(-0.5, 0)
position = Vector2(-0.5, 4)
rotation = 6.28319
[node name="Node2D" type="Node2D" parent="Sprites"]
@ -421,17 +420,23 @@ offset = Vector2(0, -12)
hframes = 7
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -2)
shape = SubResource("RectangleShape2D_bfqew")
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Items")]
position = Vector2(0, -4)
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Hotbar")]
script = ExtResource("17_5rur0")
Hotbar = []
Items = []
[node name="DocLance" parent="Inventory" instance=ExtResource("18_jblpi")]
[node name="DocLance" parent="Inventory" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor") instance=ExtResource("18_jblpi")]
Hitbox = NodePath("Hitbox")
AnimationPlayer = NodePath("AnimationPlayer")
ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles")
StateMachine = NodePath("State")
Anchor = NodePath("Anchor")
HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand")
[node name="Hurtbox" parent="." instance=ExtResource("20_dwjfv")]
position = Vector2(0, 4)
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2(0, -8)

View File

@ -115,7 +115,7 @@ public partial class NPC : Character
}
float score = 0;
score += Position.DistanceTo(character.Position);
score -= Position.DistanceTo(character.Position);
if (score < bestScore)
{

View File

@ -111,6 +111,14 @@ public sealed partial class Player : Character
}
}
public override void _UnhandledInput(InputEvent @event)
{
if (StateMachine != null)
{
StateMachine.UnhandledInput(@event);
}
}
/// <summary>
/// Respawns the player with full health and plays spawn animation
/// </summary>

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=72 format=3 uid="uid://b2254pup8k161"]
[gd_scene load_steps=74 format=3 uid="uid://b2254pup8k161"]
[ext_resource type="Script" path="res://Characters/Player.cs" id="1_flygr"]
[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_ngsgt"]
@ -34,7 +34,9 @@
[ext_resource type="Texture2D" uid="uid://bd8l8kafb42dt" path="res://Assets/Sprites/Particles/circle.png" id="22_uefct"]
[ext_resource type="Texture2D" uid="uid://bcgm3r168qjn3" path="res://Assets/Sprites/Particles/cast-effect.png" id="24_njn4h"]
[ext_resource type="Script" path="res://Items/PlayerInventory.cs" id="30_y2wmw"]
[ext_resource type="PackedScene" uid="uid://cgg0sfm2qeiwn" path="res://Items/Weapons/Bow.tscn" id="31_mofvy"]
[ext_resource type="PackedScene" uid="uid://dvqap2uhcah63" path="res://Items/Weapons/Sword.tscn" id="31_ql4as"]
[ext_resource type="PackedScene" uid="uid://5y1acxl4j4n7" path="res://Items/Weapons/Pugio.tscn" id="32_6ffmm"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_h78y7"]
shader = ExtResource("2_ngsgt")
@ -562,7 +564,7 @@ color_ramp = SubResource("GradientTexture1D_3jlnh")
light_mode = 1
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bfqew"]
size = Vector2(12, 6)
size = Vector2(12, 8)
[sub_resource type="LabelSettings" id="LabelSettings_q5h1n"]
font_size = 24
@ -686,7 +688,6 @@ libraries = {
[node name="Effects" type="Node2D" parent="."]
unique_name_in_owner = true
position = Vector2(0, 2)
[node name="RollParticles" type="GPUParticles2D" parent="Effects"]
emitting = false
@ -759,7 +760,6 @@ stream = ExtResource("12_vvem5")
[node name="TargetTracer" parent="Effects" instance=ExtResource("22_hxi53")]
unique_name_in_owner = true
position = Vector2(0, -4)
[node name="Camera2D" parent="." instance=ExtResource("4_ym125")]
zoom = Vector2(4, 4)
@ -769,7 +769,7 @@ position_smoothing_speed = 8.0
unique_name_in_owner = true
y_sort_enabled = true
use_parent_material = true
position = Vector2(0, 2)
position = Vector2(-0.5, 4)
rotation = 6.28319
[node name="Node2D" type="Node2D" parent="Sprites"]
@ -796,7 +796,6 @@ offset = Vector2(-9.5, -14)
hframes = 6
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -1)
shape = SubResource("RectangleShape2D_bfqew")
[node name="Debug" type="Control" parent="."]
@ -816,20 +815,38 @@ horizontal_alignment = 1
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Hotbar")]
y_sort_enabled = true
position = Vector2(0, -2)
script = ExtResource("30_y2wmw")
Hotbar = [NodePath("Sword"), null, null]
Hotbar = [NodePath("Sword"), NodePath("Bow"), NodePath("Pugio")]
InventoryMap = {
"equip_1": 0,
"equip_2": 1,
"equip_3": 2
}
[node name="Bow" parent="Inventory" node_paths=PackedStringArray("StateMachine") instance=ExtResource("31_mofvy")]
visible = false
StateMachine = NodePath("StateMachine")
[node name="RemoteTransform2D2" type="RemoteTransform2D" parent="Inventory"]
position = Vector2(0, 4)
[node name="Sword" parent="Inventory" instance=ExtResource("31_ql4as")]
[node name="Sword" parent="Inventory" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor") instance=ExtResource("31_ql4as")]
visible = false
Hitbox = NodePath("Hitbox")
AnimationPlayer = NodePath("AnimationPlayer")
ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles")
StateMachine = NodePath("State")
Anchor = NodePath("Anchor")
HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand")
[node name="Pugio" parent="Inventory" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor") instance=ExtResource("32_6ffmm")]
visible = false
Hitbox = NodePath("Hitbox")
AnimationPlayer = NodePath("AnimationPlayer")
ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles")
StateMachine = NodePath("State")
Anchor = NodePath("Anchor")
HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand")
[node name="Hurtbox" parent="." node_paths=PackedStringArray("InvincibilityTimer") instance=ExtResource("9_avyu4")]
visible = false
@ -857,7 +874,7 @@ collide_with_bodies = false
script = ExtResource("13_hs3u1")
[node name="PointLight2D" type="PointLight2D" parent="."]
position = Vector2(0, -8)
position = Vector2(0, -4)
blend_mode = 2
shadow_enabled = true
shadow_filter = 2

View File

@ -280,19 +280,25 @@ texture = ExtResource("11_wp6i2")
[node name="HurtSound" type="AudioStreamPlayer2D" parent="Effects"]
stream = ExtResource("12_iwry7")
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Items")]
[node name="Inventory" type="Node2D" parent="." node_paths=PackedStringArray("Hotbar")]
y_sort_enabled = true
position = Vector2(0, -4)
script = ExtResource("3_ktm40")
Hotbar = []
Items = []
[node name="Sword" parent="Inventory" instance=ExtResource("4_4gsqu")]
[node name="Sword" parent="Inventory" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor") instance=ExtResource("4_4gsqu")]
Hitbox = NodePath("Hitbox")
AnimationPlayer = NodePath("AnimationPlayer")
ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles")
StateMachine = NodePath("State")
Anchor = NodePath("Anchor")
HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand")
[node name="Sprites" type="Node2D" parent="."]
unique_name_in_owner = true
y_sort_enabled = true
use_parent_material = true
position = Vector2(-0.5, 0)
position = Vector2(-0.5, 4)
[node name="Sprite2D" type="Sprite2D" parent="Sprites"]
y_sort_enabled = true
@ -303,11 +309,10 @@ offset = Vector2(-10, -20)
hframes = 10
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -4)
shape = SubResource("RectangleShape2D_v8rkj")
[node name="Hurtbox" parent="." instance=ExtResource("11_sj7u0")]
position = Vector2(0, -8)
position = Vector2(0, -4)
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
shape = SubResource("RectangleShape2D_kyos5")

File diff suppressed because one or more lines are too long

View File

@ -36,4 +36,13 @@ public partial class CharacterStateMachine : StateMachine<CharacterState>
ChangeState(state);
}
}
public void UnhandledInput(InputEvent @event)
{
var state = CurrentState.UnhandledInput(@event);
if (state is CharacterState)
{
ChangeState(state);
}
}
}