Switching from FindObjectsOfTypeAll to single unit.

Good evening.

I am still very new to all this so please be gentle.

I have a character that wonders around my scene. I am attempting to use the Apex Path speed controllers / humanoid speed component to have three speed settings for each character “crawl, walk & run”. After adapting one of their examples to be GetKeyDown rather than gui buttons, I have achieved this. Alas, the script affects any selected unit, not just the unit I have the script on (important as different characters need different speed settings - so would like it to currently only affect he individual characters). I believe it’s due to these lines:

 private void Awake()
        {
            _speedControllers = Resources.FindObjectsOfTypeAll<HumanoidSpeedComponent>();
        }

I believe I need to change the “FindObjectsOfTypeAll” to just “FindMyCharacter” as it were, but have no idea what to change it to so it’s only searching to apply the Speed Controllers to the character that has the script added to it.

Full script:

(not sure I need all the “using”'s but I stuck as many as I could possibly need just to make sure for now - again, noob).

{
    using System.Collections.Generic;
    using System.Collections;
    using Apex.Steering;
    using Apex.Steering.Components;
    using UnityEngine;

    /// <summary>
    /// A component that controls the speed of all <see cref="Apex.Steering.Components.HumanoidSpeedComponent"/> in the scene
    /// </summary>
    [AddComponentMenu("Apex/Examples/Omni Speed Controller", 1013)]
    public class ApexUnitSpeedIncreaseIndividual : MonoBehaviour
    {
        private HumanoidSpeedComponent[] _speedControllers;


        private void Awake()
        {
            _speedControllers = Resources.FindObjectsOfTypeAll<HumanoidSpeedComponent>();
        }
        private void Update()
        {
            if (Input.GetKeyDown("f1"))

                foreach (var c in _speedControllers)
                {
                    c.Crawl();
               
        }
        if (Input.GetKeyDown("f2"))

                foreach (var c in _speedControllers)
                {
                    c.Walk();
                }

               

                if (Input.GetKeyDown("f3"))

                foreach (var c in _speedControllers)
                {
                    c.Run();
                }
        }




            }
        }

You need a singleton I think.

public class HumanoidSpeedComponent : MonoBehaviour {
public static HumanoidSpeedComponent instance;

void Awake() {
instance = this;
}

//anywhere else
HumanoidSpeedComponent.instance.transform.position = Vector3.zero;

Thank you for the tip but I’ve decided to move onto a different path finding system for now. I’ll come back to Apex Path in the future so will give it a go. Thank you again.