adding physics object statue
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var speed:int = 50
|
||||
@export var speed:int = 150
|
||||
@export var max_speed:int = 350
|
||||
@export var push_power:int = 50 + speed
|
||||
@onready var health := max_health
|
||||
@@ -12,10 +12,7 @@ extends CharacterBody2D
|
||||
@onready var player := get_node(".")
|
||||
#Animation
|
||||
@onready var anim_tree = $AnimationTree
|
||||
@onready var atk_str := "parameters/attacking/current"
|
||||
@onready var mov_str := "parameters/moving/current"
|
||||
@onready var damage_str := "parameters/damaged/current"
|
||||
@onready var disabled_str := "parameters/disabled/current"
|
||||
@onready var anim_mode = anim_tree.get("parameters/playback")
|
||||
#Other
|
||||
@export var value:int = 0
|
||||
|
||||
@@ -49,6 +46,8 @@ signal player_killed
|
||||
|
||||
func _ready():
|
||||
if not is_multiplayer_authority(): return
|
||||
print("Setting IDLE")
|
||||
#anim_mode.travel("idle")
|
||||
|
||||
|
||||
func value_changed_func(amount: int) -> void:
|
||||
@@ -58,9 +57,11 @@ func value_changed_func(amount: int) -> void:
|
||||
func set_disabled(is_disabled:bool):
|
||||
player_disabled = is_disabled
|
||||
if is_disabled:
|
||||
anim_tree.set(disabled_str, 1)
|
||||
anim_tree.set("parameters/DamageOneShot/request", 1)
|
||||
#anim_tree.set(disabled_str, 1)
|
||||
else:
|
||||
anim_tree.set(disabled_str, 0)
|
||||
pass
|
||||
#anim_tree.set(disabled_str, 0)
|
||||
|
||||
func speed_changed_func(amount: int) -> void:
|
||||
speed = speed + amount
|
||||
@@ -74,9 +75,11 @@ func speed_changed_func(amount: int) -> void:
|
||||
|
||||
# reset our invulnerability animations
|
||||
func _on_invulnerable_timer_timeout():
|
||||
anim_tree.set(damage_str, 0)
|
||||
pass
|
||||
#anim_tree.set(damage_str, 0)
|
||||
|
||||
func health_changed_func(amount: int):
|
||||
print("Health DAMAGED!")
|
||||
if amount < 0:
|
||||
if invulnerability_timer.is_stopped():
|
||||
invulnerability_timer.start()
|
||||
@@ -87,13 +90,20 @@ func health_changed_func(amount: int):
|
||||
#TODO: Respawn char
|
||||
else:
|
||||
print("Setting health frame: ", health)
|
||||
anim_tree.set(damage_str, 1)
|
||||
#anim_tree.set(damage_str, 1)
|
||||
else:
|
||||
health = health + amount
|
||||
emit_signal("health_changed", health)
|
||||
|
||||
|
||||
func set_animation_state():
|
||||
if(velocity != Vector2.ZERO):
|
||||
anim_tree.travel("walk")
|
||||
else:
|
||||
pass
|
||||
#anim_tree.travel("idle")
|
||||
|
||||
func attack_finished():
|
||||
anim_tree.set(atk_str, 0)
|
||||
#anim_tree.set(atk_str, 0)
|
||||
is_attacking = false
|
||||
|
||||
func get_input():
|
||||
@@ -117,10 +127,16 @@ func get_input():
|
||||
is_attacking = true
|
||||
if player_facing == "left":
|
||||
player_sprite.flip_h = true
|
||||
anim_tree.set(atk_str, 1)
|
||||
print("Attacking!")
|
||||
#anim_tree.set("parameters/AttackOneShot/active", true)
|
||||
anim_tree.set("parameters/AttackOneShot/request", 1)
|
||||
#anim_tree.set(atk_str, 1)
|
||||
else:
|
||||
player_sprite.flip_h = false
|
||||
anim_tree.set(atk_str, 1)
|
||||
anim_tree.set("parameters/AttackOneShot/request", 1)
|
||||
#anim_tree.set(atk_str, 1)
|
||||
#anim_mode.travel("attack")
|
||||
next_attack_time = now + attack_speed
|
||||
if equipped:
|
||||
pass
|
||||
#spawned_item = load(ItemDatabase.Castable_objects[equipped.item_name]).instantiate()
|
||||
@@ -133,31 +149,27 @@ func get_input():
|
||||
#next_attack_time = now + attack_speed
|
||||
velocity = Vector2()
|
||||
var direction : String
|
||||
# if not input_active:
|
||||
# return
|
||||
if Input.is_action_pressed("right") and not is_attacking:
|
||||
player_facing = "right"
|
||||
player_sprite.flip_h = false
|
||||
velocity.x += 1
|
||||
anim_tree.set(mov_str, 1)
|
||||
if Input.is_action_pressed("left") and not is_attacking:
|
||||
player_sprite.flip_h = true
|
||||
player_facing = "left"
|
||||
velocity.x -= 1
|
||||
anim_tree.set(mov_str, 1)
|
||||
if Input.is_action_pressed("down") and not is_attacking:
|
||||
direction = "down"
|
||||
velocity.y += 1
|
||||
anim_tree.set(mov_str, 1)
|
||||
if Input.is_action_pressed("up") and not is_attacking:
|
||||
direction = "up"
|
||||
velocity.y -= 1
|
||||
anim_tree.set(mov_str, 1)
|
||||
|
||||
|
||||
velocity = velocity.normalized() * speed
|
||||
if velocity == Vector2.ZERO:
|
||||
anim_tree.set(mov_str, 0)
|
||||
anim_tree.set("parameters/walkIdleBlend/blend_amount", 1)
|
||||
else:
|
||||
anim_tree.set("parameters/walkIdleBlend/blend_amount", 0)
|
||||
|
||||
func _physics_process(delta):
|
||||
# if not is_multiplayer_authority():
|
||||
@@ -174,8 +186,11 @@ func _physics_process(delta):
|
||||
if collider.is_in_group("moveable"):
|
||||
var normal = collision.get_normal()
|
||||
collider.apply_central_impulse(-collision.get_normal() * push_power)
|
||||
# push back the player when player pushed
|
||||
#player_hit.is_player_hit = true
|
||||
#player_hit.hit_velocity = push_power * .1
|
||||
|
||||
if player_hit.is_player_hit:
|
||||
if player_hit.is_player_hit: # moves player over time
|
||||
velocity = Vector2.ZERO
|
||||
set_disabled(true)
|
||||
player_hit.is_player_hit = false
|
||||
@@ -192,6 +207,9 @@ func _physics_process(delta):
|
||||
# $Networking.flipped_h = player_sprite.flip_h
|
||||
# $Networking.sync_frame_coords = player_sprite.get_frame_coords()
|
||||
|
||||
|
||||
|
||||
|
||||
func move_player(c_velocity: Vector2):
|
||||
# rpc(&'update_movement', velocity)
|
||||
var collided = move_and_collide(c_velocity)
|
||||
|
@@ -1,12 +1,59 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://c1gncjamuavvs"]
|
||||
[gd_scene load_steps=20 format=3 uid="uid://c1gncjamuavvs"]
|
||||
|
||||
[ext_resource type="Script" path="res://Characters/test_player/test_player.gd" id="1_6aci1"]
|
||||
[ext_resource type="Texture2D" uid="uid://cs5o8bykug82q" path="res://Characters/test_player/WARRIOR SKELETON SS 2.png" id="1_8pmbp"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8xegc"]
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a08cb"]
|
||||
size = Vector2(22, 20)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ue5sa"]
|
||||
[sub_resource type="Animation" id="Animation_1103t"]
|
||||
resource_name = "attack"
|
||||
length = 0.65
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame_coords")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [Vector2i(0, 5), Vector2i(1, 5), Vector2i(2, 5), Vector2i(3, 5)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_vnyb5"]
|
||||
resource_name = "damage"
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:self_modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0001, 0.05, 0.1, 0.14, 0.18, 0.23, 0.28, 0.32, 0.36, 0.41, 0.46, 0.5, 0.54, 0.59, 0.64, 0.68, 0.72, 0.77, 0.82, 0.86, 0.9, 0.95, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_gq32v"]
|
||||
resource_name = "die"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame_coords")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.9),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [Vector2i(0, 4), Vector2i(1, 4), Vector2i(2, 4), Vector2i(3, 4), Vector2i(4, 4)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_r2lqp"]
|
||||
resource_name = "idle"
|
||||
length = 2.0
|
||||
loop_mode = 1
|
||||
@@ -23,10 +70,10 @@ tracks/0/keys = {
|
||||
"values": [Vector2i(0, 0), Vector2i(1, 0), Vector2i(2, 0), Vector2i(3, 0), Vector2i(4, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_o87wd"]
|
||||
[sub_resource type="Animation" id="Animation_psmw8"]
|
||||
resource_name = "walk"
|
||||
length = 2.5
|
||||
loop_mode = 1
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
@@ -34,62 +81,99 @@ tracks/0/path = NodePath("Sprite2D:frame_coords")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.4, 0.8, 1.2, 1.6, 2.1),
|
||||
"times": PackedFloat32Array(0, 0.17, 0.34, 0.51, 0.74, 0.96),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [Vector2i(0, 1), Vector2i(1, 1), Vector2i(2, 1), Vector2i(3, 1), Vector2i(4, 1), Vector2i(5, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6p4h5"]
|
||||
resource_name = "attack"
|
||||
length = 0.65
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame_coords")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [Vector2i(0, 5), Vector2i(1, 5), Vector2i(2, 5), Vector2i(3, 5)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_0a2an"]
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_rx5pu"]
|
||||
_data = {
|
||||
"attack": SubResource("Animation_6p4h5"),
|
||||
"idle": SubResource("Animation_ue5sa"),
|
||||
"walk": SubResource("Animation_o87wd")
|
||||
"attack": SubResource("Animation_1103t"),
|
||||
"damage": SubResource("Animation_vnyb5"),
|
||||
"die": SubResource("Animation_gq32v"),
|
||||
"idle": SubResource("Animation_r2lqp"),
|
||||
"walk": SubResource("Animation_psmw8")
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_h4jmi"]
|
||||
nodes/output/position = Vector2(900, 140)
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_7kx25"]
|
||||
|
||||
[node name="test_player" type="CharacterBody2D"]
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_gm2dr"]
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_cl8pn"]
|
||||
animation = &"attack"
|
||||
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_tyu0k"]
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_f5cnp"]
|
||||
animation = &"damage"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4qn65"]
|
||||
animation = &"die"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_kqkvd"]
|
||||
animation = &"idle"
|
||||
|
||||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_66hu3"]
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jxg51"]
|
||||
animation = &"walk"
|
||||
|
||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_6ake6"]
|
||||
graph_offset = Vector2(-1059.2, -82.3198)
|
||||
nodes/AttackOneShot/node = SubResource("AnimationNodeOneShot_7kx25")
|
||||
nodes/AttackOneShot/position = Vector2(-320, 60)
|
||||
nodes/DieOneShot/node = SubResource("AnimationNodeOneShot_gm2dr")
|
||||
nodes/DieOneShot/position = Vector2(-120, 180)
|
||||
nodes/attack_anim/node = SubResource("AnimationNodeAnimation_cl8pn")
|
||||
nodes/attack_anim/position = Vector2(-560, 200)
|
||||
nodes/damageOneShot/node = SubResource("AnimationNodeOneShot_tyu0k")
|
||||
nodes/damageOneShot/position = Vector2(100, 320)
|
||||
nodes/damage_anim/node = SubResource("AnimationNodeAnimation_f5cnp")
|
||||
nodes/damage_anim/position = Vector2(-200, 460)
|
||||
nodes/die_anim/node = SubResource("AnimationNodeAnimation_4qn65")
|
||||
nodes/die_anim/position = Vector2(-440, 340)
|
||||
nodes/idle_anim/node = SubResource("AnimationNodeAnimation_kqkvd")
|
||||
nodes/idle_anim/position = Vector2(-940, 60)
|
||||
nodes/output/position = Vector2(400, 340)
|
||||
nodes/walkIdleBlend/node = SubResource("AnimationNodeBlend2_66hu3")
|
||||
nodes/walkIdleBlend/position = Vector2(-660, -40)
|
||||
nodes/walk_anim/node = SubResource("AnimationNodeAnimation_jxg51")
|
||||
nodes/walk_anim/position = Vector2(-920, -80)
|
||||
node_connections = [&"output", 0, &"damageOneShot", &"AttackOneShot", 0, &"walkIdleBlend", &"AttackOneShot", 1, &"attack_anim", &"DieOneShot", 0, &"AttackOneShot", &"DieOneShot", 1, &"die_anim", &"damageOneShot", 0, &"DieOneShot", &"damageOneShot", 1, &"damage_anim", &"walkIdleBlend", 0, &"walk_anim", &"walkIdleBlend", 1, &"idle_anim"]
|
||||
|
||||
[node name="test_player" type="CharacterBody2D" groups=["player"]]
|
||||
script = ExtResource("1_6aci1")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(1, 2)
|
||||
shape = SubResource("RectangleShape2D_8xegc")
|
||||
shape = SubResource("RectangleShape2D_a08cb")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
z_index = 1
|
||||
texture = ExtResource("1_8pmbp")
|
||||
hframes = 6
|
||||
vframes = 6
|
||||
frame = 33
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_0a2an")
|
||||
"": SubResource("AnimationLibrary_rx5pu")
|
||||
}
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="."]
|
||||
tree_root = SubResource("AnimationNodeBlendTree_h4jmi")
|
||||
tree_root = SubResource("AnimationNodeBlendTree_6ake6")
|
||||
anim_player = NodePath("../AnimationPlayer")
|
||||
active = true
|
||||
parameters/AttackOneShot/active = false
|
||||
parameters/AttackOneShot/request = 0
|
||||
parameters/DieOneShot/active = false
|
||||
parameters/DieOneShot/request = 0
|
||||
parameters/damageOneShot/active = false
|
||||
parameters/damageOneShot/request = 0
|
||||
parameters/walkIdleBlend/blend_amount = 1.0
|
||||
|
||||
[node name="player_cam" type="Camera2D" parent="."]
|
||||
modulate = Color(0, 0, 0, 1)
|
||||
current = true
|
||||
|
||||
[node name="InvulnerableTimer" type="Timer" parent="."]
|
||||
|
Reference in New Issue
Block a user