Problem when Getting a component from a non Mono Behavior class.

I am sort of new to Unity and I ran into this problem when trying to create an animator script to work with the RigidbodyFirstPersonController script in Unity standard assets.This involves getting booleans from it which I have created. "ArgumentException: GetComponent requires that the requested component ‘MovementSettings’ derives from MonoBehaviour or Component or is an interface."This is the error message I got when playing the game. Everything else is fine but the animations don’t seem to play because of this. This is my first Unity answers so tell me if I should show more or go more in depth. Please tell me if there is an easier way to make my way around it or fixing it would be better.

GetComponent can only get references to components as the name might suggest. The nested class MovementSetting is a pure data class. The “RigidbodyFirstPersonController” component most likely has a public variable of that type.

It actually looks like this:

public MovementSettings movementSettings = new MovementSettings();

So what you have to do is get the reference to the RigidbodyFirstPersonController component by using GetComponent and just access it’s movementSettings variable

var rfpc = thePlayer.GetComponent<RigidbodyFirstPersonController>();

bool isRunningAnim = rfpc.movementSettings.isRunning;
bool isWalkingAnim = rfpc.movementSettings.isWalking;

using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;

public class PlayerAnimatorControllerScript : MonoBehaviour {
Animator animator;
void Start ()
{
animator = GetComponent();
}

void Update ()
{
    GameObject thePlayer = GameObject.Find("RigidBodyFPSController");
    RigidbodyFirstPersonController.MovementSettings playerScript = thePlayer.GetComponent<RigidbodyFirstPersonController.MovementSettings>();

    bool isRunningAnim = playerScript.isRunning;
    bool isWalkingAnim = playerScript.isWalking;

    animator.SetBool("RunAnim", isRunningAnim);
    animator.SetBool("WalkAnim", isWalkingAnim);

There is a lot more animations than just those two but they are the same style.

namespace UnityStandardAssets.Characters.FirstPerson
{
[RequireComponent(typeof (Rigidbody))]
[RequireComponent(typeof (CapsuleCollider))]
public class RigidbodyFirstPersonController : MonoBehaviour
{

    [Serializable]
    public class MovementSettings

I noticed that the problem was here, the movement settings did not have a MonoBehaviour. I changed it to a MonoBehaviour but another error occurred. I created a debug.log that would tell me if it was working like so,
if (input.y > 0 && Input.GetKey(RunKey))
{
isRunning = true;
Debug.Log(“IsRunning”);
}
else
{
isRunning = false;
}
Is running played in the console which meant it was working but I still had that error.

Thank You for the help. It now works out well apart from the animation looping itself after activation but I can solve that.@Bunny83