Skip to main content
2 of 3
Added more information about the logic errors of using GetComponent<C>() on Components but not GameObjects.
LifGwaethrakindo
  • 1.4k
  • 2
  • 15
  • 27

FirstPersonCharacter itself does not have Blur component, but the GameObject that has it attached does:

[SerializeField] FirstPersonController FPC; /// <summary>Your First Person Controller.</summary>
/// Option 1.
private Blur blur; /// <summary>Blur's Script.</summary>
/// Option 2.
[Serializefield] GameObject objWithPFCAndBlur; /// <summary>So you could get both components from this GameObject.</summary>

void Awake()
{
    blur = FPC.gameObject.GetComponent<Blur>();
    if(blur != null)
    { /// As a good practice, you should do null checkings, on cases like this.
         Debug.LogError("There was no Blur attached to GameObject");
    }
}

Maybe you had problems because Components (such as Rigidbodys, MonoBehaviours, Colliders, etc) can have Components attached (so you can use GetComponent() method), but what usually you do on inspector is attaching Components to a GameObject, which was the case, FPC does not have a Blur attached, as you can see on your GameObject's inspector.

Hope that solves your issue.

LifGwaethrakindo
  • 1.4k
  • 2
  • 15
  • 27