Browse Source

Make players spawn on side depending on team

Also add variation in spawn point, so that all spawns are not on top of
each other
master
Luna 7 years ago
parent
commit
f58e0cfab3
3 changed files with 26 additions and 2 deletions
  1. +9
    -0
      scenes/world.tscn
  2. +1
    -0
      scripts/lobby.gd
  3. +16
    -2
      scripts/player.gd

+ 9
- 0
scenes/world.tscn View File

@ -176,4 +176,13 @@ lines_skipped = 0
max_lines_visible = -1 max_lines_visible = -1
_sections_unfolded = [ "Anchor", "Focus", "Grow Direction", "Hint", "Margin", "Material", "Mouse", "Pause", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts", "custom_styles" ] _sections_unfolded = [ "Anchor", "Focus", "Grow Direction", "Hint", "Margin", "Material", "Mouse", "Pause", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts", "custom_styles" ]
[node name="LeftSpawn" type="Spatial" parent="." index="6"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.96426, 9.36109 )
_sections_unfolded = [ "Transform" ]
[node name="RightSpawn" type="Spatial" parent="." index="7"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.87156, 0 )

+ 1
- 0
scripts/lobby.gd View File

@ -137,6 +137,7 @@ remote func pre_configure_game():
var player = load("res://scenes/heroes/" + str(hero) + ".tscn").instance() var player = load("res://scenes/heroes/" + str(hero) + ".tscn").instance()
player.set_name(str(p)) player.set_name(str(p))
player.set_network_master(p) player.set_network_master(p)
player.player_info = player_info[p]
get_node("/root/world/players").call_deferred("add_child", player) get_node("/root/world/players").call_deferred("add_child", player)
rpc_id(1, "done_preconfiguring", self_peer_id) rpc_id(1, "done_preconfiguring", self_peer_id)


+ 16
- 2
scripts/player.gd View File

@ -6,14 +6,13 @@ var view_sensitivity = 0.25
var yaw = 0 var yaw = 0
var pitch = 0 var pitch = 0
var timer = 0
# Walking speed and jumping height are defined later. # Walking speed and jumping height are defined later.
var walk_speed = 2 var walk_speed = 2
var jump_speed = 3 var jump_speed = 3
const air_accel = .6 const air_accel = .6
var floor_friction = 0.92 var floor_friction = 0.92
var air_friction = 0.98 var air_friction = 0.98
var player_info # Set by lobby
var health = 100 var health = 100
var stamina = 10000 var stamina = 10000
@ -34,6 +33,21 @@ func _ready():
if is_network_master(): if is_network_master():
get_node("Yaw/Pitch/Camera").make_current() get_node("Yaw/Pitch/Camera").make_current()
spawn()
func spawn():
var placement = Vector3()
var x_varies = 10
var y_varies = 20
# No Z, because that's the left-right question
if player_info.is_right_team:
placement = get_node("/root/world/RightSpawn").get_translation()
else:
placement = get_node("/root/world/LeftSpawn").get_translation()
# So we don't all spawn on top of each other
placement.x += rand_range(0, x_varies)
placement.y += rand_range(0, y_varies)
set_translation(placement)
func _input(event): func _input(event):
if is_network_master(): if is_network_master():


Loading…
Cancel
Save