Question by 
               Adrian-Salarda · Apr 22, 2016 at 03:04 AM · 
                functioncollider2dbooleanboolontriggerenter2d  
              
 
              Need help with writing a bool to call a function
At the moment I'm currently trying to have the player collide a trigger, if the player triggers it call a the AttackPlayer function. Also I have a bool to set if true, then call that function. However I haven't coded for awhile and still somewhat new to c# so if I could get some urgent help, it would be greatly appreciated.
using UnityEngine; using System.Collections;
public class Enemy : MonoBehaviour {
 public Transform target; 
 public float speed = 2f; 
 private float minDistance = 5f;
 private float range; 
 private bool chase = false;
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void AttackPlayer () { 
     range = Vector2.Distance (transform.position, target.position); 
     if (range > minDistance) { 
         transform.position = Vector2.MoveTowards (transform.position, target.position, speed * Time.deltaTime);
     } 
 } 
 void OnTriggerEnter2D (Collider2D target) { 
         
     if (target.tag == "Player") { 
         chase = true; 
     } 
     if (chase == true) { 
     }
 }
 
               }
               Comment
              
 
               
              Your answer