46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
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.");
|
|
|
|
}
|
|
}
|
|
}
|