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
|
||||
|
Reference in New Issue
Block a user