Hi everyone, is it possible to access a character controller’s properties such as isGrounded or Move without declaring one? I have a gameobject that has a character controller and I simply would like to reference that rather than having to assign it to a declared Character Controller within my script. I’ve tried gameobject.CharacterController.Move
and gameobject.CharacterController.isGrounded but it neither of them worked.
1 Answer
1You can access it by using :
gameObject.GetComponent<CharacterController>().isGrounded
I might add that if you do this frequently, it's much more efficient to cache the CharacterController in a field or property.
– asafsitner