MP sync working, redoing all menus now
This commit is contained in:
		@@ -9,6 +9,7 @@ extends CharacterBody2D
 | 
			
		||||
@export var attack_speed := 2000
 | 
			
		||||
@export var throwback_strength := 2
 | 
			
		||||
@onready var player_sprite = $Sprite2D
 | 
			
		||||
@onready var player_cam = $player_cam
 | 
			
		||||
@onready var player := get_node(".")
 | 
			
		||||
#Animation
 | 
			
		||||
@onready var anim_tree = $AnimationTree
 | 
			
		||||
@@ -44,9 +45,19 @@ signal value_changed
 | 
			
		||||
signal health_changed
 | 
			
		||||
signal player_killed
 | 
			
		||||
 | 
			
		||||
func _enter_tree():
 | 
			
		||||
	set_multiplayer_authority(str(name).to_int())
 | 
			
		||||
 | 
			
		||||
@rpc("any_peer")
 | 
			
		||||
func set_spawn_location(spawn_position: Vector2):
 | 
			
		||||
	print("RPC position update! from PEER ID: ", player.name, spawn_position)
 | 
			
		||||
	set_position(spawn_position)
 | 
			
		||||
 | 
			
		||||
func _ready():
 | 
			
		||||
	if not is_multiplayer_authority(): return
 | 
			
		||||
	print("Setting IDLE")
 | 
			
		||||
	print("Setting IDLE: ", get_position())
 | 
			
		||||
	player_cam.make_current()
 | 
			
		||||
	#player_cam.current = true # for mp to set the camera
 | 
			
		||||
	#anim_mode.travel("idle")
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
@@ -107,6 +118,9 @@ func attack_finished():
 | 
			
		||||
	is_attacking = false
 | 
			
		||||
	
 | 
			
		||||
func get_input():
 | 
			
		||||
	if Input.is_action_just_pressed("reset_pos"):
 | 
			
		||||
		print("REsetting player POS: ")
 | 
			
		||||
		set_position(Vector2(-110, 561))
 | 
			
		||||
	if Input.is_action_just_pressed("print_pos"):
 | 
			
		||||
		print("PLAYER POSITION!: ", player.get_position())
 | 
			
		||||
	if Input.is_action_just_pressed("show_inventory"):
 | 
			
		||||
@@ -170,8 +184,10 @@ func get_input():
 | 
			
		||||
		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(): return
 | 
			
		||||
#	if not is_multiplayer_authority():
 | 
			
		||||
#		get_input()
 | 
			
		||||
#		move_and_slide()
 | 
			
		||||
@@ -185,7 +201,11 @@ func _physics_process(delta):
 | 
			
		||||
		var collider = collision.get_collider()
 | 
			
		||||
		if collider.is_in_group("moveable"):
 | 
			
		||||
			var normal = collision.get_normal()
 | 
			
		||||
			collider.apply_central_impulse(-collision.get_normal() * push_power)
 | 
			
		||||
			collider.apply_central_force(-collision.get_normal() * push_power)
 | 
			
		||||
			#collider.applied_force = -collision.get_normal() * push_power
 | 
			
		||||
			#collider.move_object.rpc()
 | 
			
		||||
 | 
			
		||||
			#collider.apply_central_impulse()
 | 
			
		||||
			# push back the player when player pushed
 | 
			
		||||
			#player_hit.is_player_hit = true
 | 
			
		||||
			#player_hit.hit_velocity = push_power * .1
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,13 @@
 | 
			
		||||
[gd_scene load_steps=20 format=3 uid="uid://c1gncjamuavvs"]
 | 
			
		||||
[gd_scene load_steps=22 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"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://0ou4asf4vsc1" path="res://UI/Inventory/Inventory.tscn" id="3_fol83"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a08cb"]
 | 
			
		||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3qub5"]
 | 
			
		||||
size = Vector2(22, 20)
 | 
			
		||||
 | 
			
		||||
[sub_resource type="Animation" id="Animation_1103t"]
 | 
			
		||||
[sub_resource type="Animation" id="Animation_v17mb"]
 | 
			
		||||
resource_name = "attack"
 | 
			
		||||
length = 0.65
 | 
			
		||||
tracks/0/type = "value"
 | 
			
		||||
@@ -22,7 +23,7 @@ tracks/0/keys = {
 | 
			
		||||
"values": [Vector2i(0, 5), Vector2i(1, 5), Vector2i(2, 5), Vector2i(3, 5)]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[sub_resource type="Animation" id="Animation_vnyb5"]
 | 
			
		||||
[sub_resource type="Animation" id="Animation_dhyjd"]
 | 
			
		||||
resource_name = "damage"
 | 
			
		||||
step = 0.01
 | 
			
		||||
tracks/0/type = "value"
 | 
			
		||||
@@ -38,7 +39,7 @@ tracks/0/keys = {
 | 
			
		||||
"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"]
 | 
			
		||||
[sub_resource type="Animation" id="Animation_jals6"]
 | 
			
		||||
resource_name = "die"
 | 
			
		||||
tracks/0/type = "value"
 | 
			
		||||
tracks/0/imported = false
 | 
			
		||||
@@ -53,7 +54,7 @@ tracks/0/keys = {
 | 
			
		||||
"values": [Vector2i(0, 4), Vector2i(1, 4), Vector2i(2, 4), Vector2i(3, 4), Vector2i(4, 4)]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[sub_resource type="Animation" id="Animation_r2lqp"]
 | 
			
		||||
[sub_resource type="Animation" id="Animation_mhxr4"]
 | 
			
		||||
resource_name = "idle"
 | 
			
		||||
length = 2.0
 | 
			
		||||
loop_mode = 1
 | 
			
		||||
@@ -70,7 +71,7 @@ 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_psmw8"]
 | 
			
		||||
[sub_resource type="Animation" id="Animation_5kwsw"]
 | 
			
		||||
resource_name = "walk"
 | 
			
		||||
loop_mode = 1
 | 
			
		||||
step = 0.01
 | 
			
		||||
@@ -87,81 +88,97 @@ tracks/0/keys = {
 | 
			
		||||
"values": [Vector2i(0, 1), Vector2i(1, 1), Vector2i(2, 1), Vector2i(3, 1), Vector2i(4, 1), Vector2i(5, 1)]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_rx5pu"]
 | 
			
		||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_mfcw3"]
 | 
			
		||||
_data = {
 | 
			
		||||
"attack": SubResource("Animation_1103t"),
 | 
			
		||||
"damage": SubResource("Animation_vnyb5"),
 | 
			
		||||
"die": SubResource("Animation_gq32v"),
 | 
			
		||||
"idle": SubResource("Animation_r2lqp"),
 | 
			
		||||
"walk": SubResource("Animation_psmw8")
 | 
			
		||||
"attack": SubResource("Animation_v17mb"),
 | 
			
		||||
"damage": SubResource("Animation_dhyjd"),
 | 
			
		||||
"die": SubResource("Animation_jals6"),
 | 
			
		||||
"idle": SubResource("Animation_mhxr4"),
 | 
			
		||||
"walk": SubResource("Animation_5kwsw")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_7kx25"]
 | 
			
		||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_lqar1"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_gm2dr"]
 | 
			
		||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_vr7py"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_cl8pn"]
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_d7310"]
 | 
			
		||||
animation = &"attack"
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_tyu0k"]
 | 
			
		||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_83svy"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_f5cnp"]
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ixc0x"]
 | 
			
		||||
animation = &"damage"
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4qn65"]
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_wmn47"]
 | 
			
		||||
animation = &"die"
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_kqkvd"]
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_poall"]
 | 
			
		||||
animation = &"idle"
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_66hu3"]
 | 
			
		||||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_cxexk"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jxg51"]
 | 
			
		||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6a4lj"]
 | 
			
		||||
animation = &"walk"
 | 
			
		||||
 | 
			
		||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_6ake6"]
 | 
			
		||||
graph_offset = Vector2(-1059.2, -82.3198)
 | 
			
		||||
nodes/AttackOneShot/node = SubResource("AnimationNodeOneShot_7kx25")
 | 
			
		||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_4pmjh"]
 | 
			
		||||
graph_offset = Vector2(-769.911, -161.25)
 | 
			
		||||
nodes/AttackOneShot/node = SubResource("AnimationNodeOneShot_lqar1")
 | 
			
		||||
nodes/AttackOneShot/position = Vector2(-320, 60)
 | 
			
		||||
nodes/DieOneShot/node = SubResource("AnimationNodeOneShot_gm2dr")
 | 
			
		||||
nodes/DieOneShot/node = SubResource("AnimationNodeOneShot_vr7py")
 | 
			
		||||
nodes/DieOneShot/position = Vector2(-120, 180)
 | 
			
		||||
nodes/attack_anim/node = SubResource("AnimationNodeAnimation_cl8pn")
 | 
			
		||||
nodes/attack_anim/node = SubResource("AnimationNodeAnimation_d7310")
 | 
			
		||||
nodes/attack_anim/position = Vector2(-560, 200)
 | 
			
		||||
nodes/damageOneShot/node = SubResource("AnimationNodeOneShot_tyu0k")
 | 
			
		||||
nodes/damageOneShot/node = SubResource("AnimationNodeOneShot_83svy")
 | 
			
		||||
nodes/damageOneShot/position = Vector2(100, 320)
 | 
			
		||||
nodes/damage_anim/node = SubResource("AnimationNodeAnimation_f5cnp")
 | 
			
		||||
nodes/damage_anim/node = SubResource("AnimationNodeAnimation_ixc0x")
 | 
			
		||||
nodes/damage_anim/position = Vector2(-200, 460)
 | 
			
		||||
nodes/die_anim/node = SubResource("AnimationNodeAnimation_4qn65")
 | 
			
		||||
nodes/die_anim/node = SubResource("AnimationNodeAnimation_wmn47")
 | 
			
		||||
nodes/die_anim/position = Vector2(-440, 340)
 | 
			
		||||
nodes/idle_anim/node = SubResource("AnimationNodeAnimation_kqkvd")
 | 
			
		||||
nodes/idle_anim/node = SubResource("AnimationNodeAnimation_poall")
 | 
			
		||||
nodes/idle_anim/position = Vector2(-940, 60)
 | 
			
		||||
nodes/output/position = Vector2(400, 340)
 | 
			
		||||
nodes/walkIdleBlend/node = SubResource("AnimationNodeBlend2_66hu3")
 | 
			
		||||
nodes/walkIdleBlend/node = SubResource("AnimationNodeBlend2_cxexk")
 | 
			
		||||
nodes/walkIdleBlend/position = Vector2(-660, -40)
 | 
			
		||||
nodes/walk_anim/node = SubResource("AnimationNodeAnimation_jxg51")
 | 
			
		||||
nodes/walk_anim/node = SubResource("AnimationNodeAnimation_6a4lj")
 | 
			
		||||
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"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_n4dy6"]
 | 
			
		||||
properties/0/path = NodePath(".:position")
 | 
			
		||||
properties/0/spawn = true
 | 
			
		||||
properties/0/sync = true
 | 
			
		||||
properties/1/path = NodePath(".:rotation")
 | 
			
		||||
properties/1/spawn = true
 | 
			
		||||
properties/1/sync = true
 | 
			
		||||
properties/2/path = NodePath("Sprite2D:frame")
 | 
			
		||||
properties/2/spawn = true
 | 
			
		||||
properties/2/sync = true
 | 
			
		||||
properties/3/path = NodePath("Sprite2D:flip_h")
 | 
			
		||||
properties/3/spawn = true
 | 
			
		||||
properties/3/sync = true
 | 
			
		||||
 | 
			
		||||
[node name="test_player" type="CharacterBody2D" groups=["player"]]
 | 
			
		||||
motion_mode = 1
 | 
			
		||||
script = ExtResource("1_6aci1")
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 | 
			
		||||
position = Vector2(1, 2)
 | 
			
		||||
shape = SubResource("RectangleShape2D_a08cb")
 | 
			
		||||
shape = SubResource("RectangleShape2D_3qub5")
 | 
			
		||||
 | 
			
		||||
[node name="Sprite2D" type="Sprite2D" parent="."]
 | 
			
		||||
z_index = 1
 | 
			
		||||
texture = ExtResource("1_8pmbp")
 | 
			
		||||
hframes = 6
 | 
			
		||||
vframes = 6
 | 
			
		||||
frame = 4
 | 
			
		||||
 | 
			
		||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
 | 
			
		||||
libraries = {
 | 
			
		||||
"": SubResource("AnimationLibrary_rx5pu")
 | 
			
		||||
"": SubResource("AnimationLibrary_mfcw3")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[node name="AnimationTree" type="AnimationTree" parent="."]
 | 
			
		||||
tree_root = SubResource("AnimationNodeBlendTree_6ake6")
 | 
			
		||||
tree_root = SubResource("AnimationNodeBlendTree_4pmjh")
 | 
			
		||||
anim_player = NodePath("../AnimationPlayer")
 | 
			
		||||
active = true
 | 
			
		||||
parameters/AttackOneShot/active = false
 | 
			
		||||
@@ -174,6 +191,13 @@ 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="."]
 | 
			
		||||
 | 
			
		||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
 | 
			
		||||
 | 
			
		||||
[node name="Inventory" parent="CanvasLayer" instance=ExtResource("3_fol83")]
 | 
			
		||||
mouse_filter = 2
 | 
			
		||||
 | 
			
		||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
 | 
			
		||||
replication_config = SubResource("SceneReplicationConfig_n4dy6")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user