SpaceClient/Scripts/Arena.gd

35 lines
1.2 KiB
GDScript
Raw Normal View History

extends Spatial
var players = {} # keys are String, values are Players
const Player = preload("res://Scenes/Player.tscn")
remote func place_player(player_id : int, position : Vector3, rotation : Vector3) -> void:
get_parent().console_print('Placing player with id: ' + String(player_id))
var player = Player.instance()
player.set_name('player' + String(player_id))
add_child(player)
player.set_translation(position)
player.set_rotation(rotation)
get_parent().console_print('Player Coords: ' + String(player.translation) + String(player.rotation))
players[player_id] = player
if player_id == get_tree().get_network_unique_id():
player.is_local = true
get_parent().console_print('Setting player with id (' + String(player_id) + ') as local')
2020-09-27 15:08:20 +00:00
player.init(player_id, get_parent().color_dict[player_id])
$Camera.register_player(player)
func init():
get_parent().arena_ready()
func play_full_plans():
for player in players.values():
player.play_full_plan()
2020-09-27 15:08:20 +00:00
func mouse_enter(player_obj : RigidBody):
players[get_tree().get_network_unique_id()].display_data(player_obj)
func mouse_exit(player_obj : RigidBody):
players[get_tree().get_network_unique_id()].clear_info_panel()