Fixed team interactions
This commit is contained in:
parent
2bfbfa5089
commit
917d52680c
5 changed files with 45 additions and 21 deletions
|
|
@ -1,10 +1,23 @@
|
|||
extends Node
|
||||
|
||||
@export var player: Player
|
||||
@export var layer: bool
|
||||
@export var inverse: bool
|
||||
|
||||
const ATTACK_LAYER: int = 0b10000
|
||||
const DEFENCE_LAYER: int = 0b100000
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
get_parent().collision_mask |= (ATTACK_LAYER if player.team == Session.TEAMS.DEFENCE else DEFENCE_LAYER)
|
||||
func on_spawned() -> void:
|
||||
var mask = (ATTACK_LAYER if (player.team == Session.TEAMS.DEFENCE != inverse) else DEFENCE_LAYER)
|
||||
if layer:
|
||||
get_parent().collision_layer |= mask
|
||||
else:
|
||||
get_parent().collision_mask |= mask
|
||||
global_update.rpc(layer,mask)
|
||||
|
||||
@rpc
|
||||
func global_update(new_layer,mask) -> void:
|
||||
if new_layer:
|
||||
get_parent().collision_layer |= mask
|
||||
else:
|
||||
get_parent().collision_mask |= mask
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ class_name Player
|
|||
|
||||
@export var team: Session.TEAMS
|
||||
|
||||
signal spawned
|
||||
|
||||
const MAX_HP = 100
|
||||
|
||||
@export var hp: int = 100:
|
||||
|
|
@ -30,10 +32,15 @@ func _physics_process(_delta: float) -> void:
|
|||
move_and_slide()
|
||||
|
||||
func die() -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
|
||||
global_position = TEMP_start_pos
|
||||
hp = MAX_HP
|
||||
|
||||
@rpc("any_peer","call_local","reliable")
|
||||
func set_start_position(start_position: Vector3):
|
||||
func set_after_spawn(start_position: Vector3,new_team: int):
|
||||
global_position = start_position
|
||||
TEMP_start_pos = global_position
|
||||
team = new_team as Session.TEAMS
|
||||
spawned.emit()
|
||||
|
|
|
|||
|
|
@ -30,5 +30,5 @@ func _input(event: InputEvent) -> void:
|
|||
rotate_camera(-event.relative.x * SENSITIVITY,-event.relative.y * SENSITIVITY)
|
||||
|
||||
@rpc("any_peer","call_local","reliable")
|
||||
func set_start_position(start_position: Vector3):
|
||||
func set_after_spawn(start_position: Vector3, _team: int):
|
||||
global_position = start_position
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue