How to access Animator state of other collider?

I tried this:

int otherAttackingState = other.gameObject.GetComponent<Animator> ().StringToHash ("Base Layer.attacking");

Got following error message:

Assets/Scripts/Attacking.cs(45,94): error CS0176: Static member `UnityEngine.Animator.StringToHash(string)’ cannot be accessed with an instance reference, qualify it with a type name instead

Any solutions?

Thanks in advance!

StringToHash is a static method. It means you have to write:

Animator.StringToHash("BaseLayer.attacking");

Put the class name only, not a reference to an actual Animator instance.