A team game with an emphasis on movement (with no shooting), inspired by Overwatch and Zineth
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB

  1. # Hero 4 stuns people at a distance, removing their linear velocity
  2. extends "res://scripts/player.gd"
  3. # --- Godot overrides ---
  4. func _ready():
  5. colored_meshes.append("Yaw/Pitch/Beam")
  6. func _process(delta):
  7. if is_network_master():
  8. var stun = Input.is_action_pressed("hero_4_stun")
  9. var is_stunning = false
  10. if stun:
  11. var look_ray = get_node("TPCamera/Camera/Ray")
  12. var stunning = look_ray.get_collider()
  13. var players = get_node("/root/Level/Players").get_children()
  14. var player = players.find(stunning)
  15. if player != -1:
  16. rpc("stun", players[player].get_name(), look_ray.get_collision_point())
  17. is_stunning = true
  18. if not is_stunning:
  19. rpc("unstun")
  20. # --- Player overrides ---
  21. # --- Own ---
  22. sync func stun(net_id, position):
  23. print("stunnnn")
  24. # Stun the thing!
  25. var player = get_node("/root/Level/Players/%s" % net_id)
  26. player.set_linear_velocity(Vector3())
  27. # Show the beam!
  28. var beam = get_node("Yaw/Pitch/Beam")
  29. get_node("Yaw/Pitch").look_at(position, Vector3(0,1,0))
  30. beam.show()
  31. var us = get_node("TPCamera/Camera").get_global_transform().origin
  32. var distance = position - us
  33. beam.scale = Vector3(1,distance.length(),1)
  34. print(beam.scale)
  35. # We move the beam up by half the scale because the position is based on the center, not the bottom
  36. beam.translation.z = -distance.length() / 2 # We face -z direction
  37. sync func unstun():
  38. var beam = get_node("Yaw/Pitch/Beam")
  39. beam.hide()