12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- ///-----------------------------------------------------------------
- /// Namespace: <Cozmo>
- /// Class: <CozmoMovementController>
- /// Description: <Statemachine to control the movement of the virtual cozmo.>
- /// Author: <Tobias Hassel> Date: <29.07.2019>
- /// Notes: <>
- ///-----------------------------------------------------------------
- ///
-
- using System;
- using UnityEngine;
-
- namespace Cozmo
- {
- // Different movementstates cozmo can use
- public enum MovementState { Stop, Forward, Right, Left }
-
- [RequireComponent(typeof(CozmoMovement))]
- public class CozmoMovementController : MonoBehaviour
- {
- [Tooltip("Current MovementState of the Robot. Change this to make the robot move.")]
- public MovementState currentMovementState = MovementState.Stop;
-
- private CozmoMovement movement; // Movement script of the robot
-
-
- void Start()
- {
- movement = GetComponent<CozmoMovement>();
- }
-
- private void FixedUpdate()
- {
- switch (currentMovementState)
- {
- case MovementState.Stop:
- movement.Move(0);
- break;
- case MovementState.Forward:
- movement.Move(1);
- break;
- case MovementState.Right:
- movement.Turn(1);
- break;
- case MovementState.Left:
- movement.Turn(-1);
- break;
- default:
- movement.Move(0);
- throw new ArgumentException("No real Movementstate was given. Default 'Stop' was chosen.");
-
- }
- }
- }
- }
|