Animation Layers Over Network

I am trying to set my animation.layer over the network. I have

animation[Animations.crouchMeleeAttack.name].layer = 1;

which works perfectly for me. Setting that allows my layer 1 to override my layer 0 animations and I can see the attack as it should happen. Where I don’t see results is over the network. I have tried

photonView.RPC("SetAnimLayer", PhotonTargets.AllBuffered, Animations.crouchMeleeAttack.name);

[RPC]
	public void SetAnimLayer(string anim){
		animation[anim].layer = 1;
	}

But no luck.

I get:

NullReferenceException: Object reference not set to an instance of an object
CharacterAnimation.configureAnimations () (at Assets/FPS Kit 2.0 C#/_CustomAssets/Scripts/FPScontroller/CharacterAnimation.cs:316)

If there is a way to set animation layers in the inspector, or a way to set it with an RPC call, that’s what I’m looking for.

An animator controller has layers already. Unless you need to constantly change the layers of an animation (which I can’t think of a use for) then you should just set the animation up to be on a different layer in the first place.

As for the flashlight script, if the variable is set in the inspector, my guess is that you might have more than one flashlight, and at least one of them is not set properly.

Trying adding this to your OnOff function

Debug.Log("Turning off", gameObject);

Then when you click on the debug, you can see which object is calling it.