In my video game I"m trying to disable a navMeshAgent making use of a bool indigenous an animatorController (tried the common bool, didn"t work-related for some reason) yet after I have scripted the bool to change and disable the mesh I gain this error. error CS0131: The left-hand side of one assignment should be a variable, a home or one indexer Id like to know what this way and how i can fix it. Below is my script for reference.

You are watching: The left-hand side of an assignment must be a variable

public class ZobieAnim : MonoBehaviour { Animator Z_Anim; publicly NavMeshAgent agent; // usage this for initialization void begin () Z_Anim = GetComponent (); // upgrade is referred to as once per frame void update () bool IsDying = Input.GetKey("e"); Z_Anim.SetBool ("IsDead", IsDying); //This is whereby the error is if (Z_Anim.GetBool ("IsDead") = true) agent.enabled = false;

*

You are using the assignment operator "=" in one if statement wherein you need to use the Equality operator "==" or (in her case) nothing at all. In your case, you should be able to do either

if (Z_Anim.GetBool ("IsDead") == true) agent.enabled = false; or, due to the fact that GetBool returns a bool

if (Z_Anim.GetBool ("IsDead")) agent.enabled = false;

*
Kingdomkey6677 · Mar 17, 2017 in ~ 11:21 pm -1
*

= is the Assignment Operator. It"s offered to assign the value or recommendation on the right side the the operator come the change on the left side of the operator.

== is the amounts to Operator. The takes the worths or references to the left and also right of the operator, and reads as true if the worths are exactly equal, and false if they"re no equal.

You"re using the an initial one and you want the second. Adjust = to ==.


*

Attachments:Up to 2 attachments (including images) deserve to be offered with a best of 524.3 kB each and 1.0 MB total.


Welcome to doyourpartparks.org doyourpartparks.org

The best place to ask and answer questions around development v doyourpartparks.org.

To aid users navigate the website we have posted a site navigating guide.

If you space a brand-new user come doyourpartparks.org doyourpartparks.org, inspect out ours FAQ for more information.

Make sure to examine out our expertise Base for typically asked doyourpartparks.org questions.

If you room a moderator, see our Moderator guidelines page.

See more: Fallout 4 The Battle For Bunker Hill ? (Spoilers?) The Battle Of Bunker Hill

We are making improvements to UA, check out the perform of changes.

*

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*