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.

CozmoMovementController.cs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public enum MovementState { Stop, Forward, Right, Left }
  6. [RequireComponent(typeof(CozmoMovement))]
  7. public class CozmoMovementController : MonoBehaviour
  8. {
  9. [Tooltip("Current MovementState of the Robot. Change this to make the robot move.")]
  10. public MovementState currentMovementState = MovementState.Stop;
  11. private CozmoMovement movement; // Movement script of the robot
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. movement = GetComponent<CozmoMovement>();
  16. }
  17. private void FixedUpdate()
  18. {
  19. switch (currentMovementState)
  20. {
  21. case MovementState.Stop:
  22. movement.Move(0);
  23. break;
  24. case MovementState.Forward:
  25. movement.Move(1);
  26. break;
  27. case MovementState.Right:
  28. movement.Turn(1);
  29. break;
  30. case MovementState.Left:
  31. movement.Turn(-1);
  32. break;
  33. default:
  34. movement.Move(0);
  35. throw new ArgumentException("No real Movementstate was given. Default 'Stop' was chosen.");
  36. }
  37. }
  38. }