123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- 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
-
-
- // Start is called before the first frame update
- 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.");
-
- }
- }
- }
|