summaryrefslogtreecommitdiffstats
path: root/assets/view_model/ViewModel.gd
diff options
context:
space:
mode:
Diffstat (limited to 'assets/view_model/ViewModel.gd')
-rw-r--r--assets/view_model/ViewModel.gd15
1 files changed, 14 insertions, 1 deletions
diff --git a/assets/view_model/ViewModel.gd b/assets/view_model/ViewModel.gd
index cb85117..6d42a5a 100644
--- a/assets/view_model/ViewModel.gd
+++ b/assets/view_model/ViewModel.gd
@@ -8,7 +8,7 @@ export var gravity = 35
var velocity = Vector3.ZERO
var snap = Vector3.DOWN
-onready var character = $BaseCharacter
+export(NodePath) onready var character = get_node(character)
onready var anchor = $Anchor
onready var spring_arm = $Anchor/SpringArm
onready var fps_label = $fps_label
@@ -64,6 +64,9 @@ func _physics_process(delta):
# Handle extra player inputs
character.is_firing = Input.is_action_pressed("fire")
+
+ if Input.is_action_just_pressed("ping"):
+ cycle_parent()
func _unhandled_input(event):
# Implement mouse aim direction
@@ -73,3 +76,13 @@ func _unhandled_input(event):
spring_arm.rotation_degrees.y -= event.relative.x * aim_sensitivity
spring_arm.rotation_degrees.y = wrapf(spring_arm.rotation_degrees.y, 0, 360)
+
+func cycle_parent():
+ var parents = get_tree().get_nodes_in_group("players")
+ var idx = parents.find(character)
+
+ if idx < 0 or idx == parents.size() - 1:
+ if parents.size() > 0:
+ character = parents[0]
+ else:
+ character = parents[idx + 1]