Global Game Jam 2021
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.

65 lines
1.5 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class ControllerBase : MonoBehaviour
  5. {
  6. public CharacterController characterController;
  7. public float speed = 6f;
  8. public float sensitivity = 10f;
  9. public GameObject body;
  10. public GameObject testChild;
  11. public YeetController yeetController;
  12. void Start()
  13. {
  14. }
  15. // Update is called once per frame
  16. void Update()
  17. {
  18. Move();
  19. //Rotate();
  20. if(Input.GetButtonDown("Fire1"))
  21. {
  22. yeetController.parent = body;
  23. switch(yeetController.yeetState)
  24. {
  25. case YeetController.YeetState.Unheld:
  26. yeetController.Hold(testChild);
  27. // Grab nearest baby
  28. break;
  29. case YeetController.YeetState.Held:
  30. yeetController.Yeet();
  31. // Yeet baby
  32. break;
  33. case YeetController.YeetState.Yeeting:
  34. // Cooldown?
  35. break;
  36. }
  37. }
  38. }
  39. void Move()
  40. {
  41. float horizontal = Input.GetAxis("Horizontal");
  42. float vertical = Input.GetAxis("Vertical");
  43. Vector3 move = transform.forward * vertical + transform.right * horizontal;
  44. characterController.Move(speed * Time.deltaTime * move);
  45. }
  46. void Rotate()
  47. {
  48. float horizontal = Input.GetAxis("Mouse Y");
  49. body.transform.Rotate(0, horizontal * sensitivity, 0);
  50. }
  51. }