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.

40 lines
1.1 KiB

  1. extends "res://scripts/player.gd"
  2. const wallride_speed = 0
  3. const wallride_speed_necessary = 15
  4. const wallride_leap_height = 20
  5. const wallride_leap_side = 10
  6. var since_on_wall = 0
  7. var last_wall_normal = Vector3()
  8. var wallride_forgiveness = .150
  9. func control_player(state):
  10. .control_player(state)
  11. wallride(state)
  12. func wallride(state):
  13. var ray = get_node("Ray")
  14. var vel = get_linear_velocity()
  15. # If our feet aren't touching, but we are colliding, we are wall-riding
  16. if !ray.is_colliding() and get_colliding_bodies() and vel.length() > wallride_speed_necessary:
  17. since_on_wall = 0
  18. last_wall_normal = state.get_contact_local_normal()
  19. else:
  20. since_on_wall += delta
  21. if since_on_wall < wallride_forgiveness:
  22. var aim = get_node("Yaw").get_global_transform().basis
  23. # Add zero gravity
  24. set_gravity_scale(0)
  25. # Allow jumping (for wall hopping!)
  26. if Input.is_action_just_pressed("jump"):
  27. var jump_impulse = -wallride_leap_side * last_wall_normal
  28. jump_impulse.y += wallride_leap_height
  29. state.apply_impulse(Vector3(), jump_impulse)
  30. else:
  31. # We need to return to falling (we aren't riding anymore)
  32. set_gravity_scale(1)