tell me what is wrong in the script? I wanted to make the enemy start running only when I appear in the frame, but he always runs.
private bool onGround;
public Transform groundSensor;
private bool cliffAhead;
public Transform cliffSensor;
public LayerMask ground;
private Rigidbody2D rb;
private Animator myAnimator;
bool isVisible = false;
public float speed;
public float jumpHeight;
private bool reacted;
// Use this for initialization
void Start () {
myAnimator = GetComponent();
rb = GetComponent();
}
// Update is called once per frame
void Update () {
if (isVisible = true) {
float x = Input.GetAxis (“Horizontal”);
Vector3 move = new Vector3 (speed * transform.localScale.x, rb.velocity.y);
rb.velocity = move;
}
}
}