New Reward function and MovementController
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
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.");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3ecda30187828846b48edbee97aebd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user