summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-09-12 02:37:04 -0400
committerMalfurious <m@lfurio.us>2022-09-12 02:37:04 -0400
commit355dcc29148461dd79815e76fa1a5a887a44ecc3 (patch)
treee7f7d3e6333b899749682d3ea963b3d307f1477c
parent40a9b7b7fb7d6e0312ae610b527d18fb2d708ba7 (diff)
downloadproject-s-355dcc29148461dd79815e76fa1a5a887a44ecc3.tar.gz
project-s-355dcc29148461dd79815e76fa1a5a887a44ecc3.zip
ViewModel cycles characters on interact/ping
Signed-off-by: Malfurious <m@lfurio.us>
-rw-r--r--assets/view_model/ViewModel.gd13
1 files changed, 13 insertions, 0 deletions
diff --git a/assets/view_model/ViewModel.gd b/assets/view_model/ViewModel.gd
index 8a818a3..6d42a5a 100644
--- a/assets/view_model/ViewModel.gd
+++ b/assets/view_model/ViewModel.gd
@@ -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]