/// <summary> /// Attack protocol /// </summary> void Attack() { Debug.Log("Attack"); if (projectile_hits > 0 && distance > 2) { projectile_hits--; Shot = (GameObject)Instantiate(Projectile, transform.position + Vector3.up, Quaternion.identity); Physics.IgnoreCollision(GetComponent <Collider>(), Shot.GetComponent <Collider>()); //Shot.GetComponent<Rigidbody>().collisionDetectionMode = CollisionDetectionMode.Continuous; //Shot.GetComponent<Rigidbody>().useGravity = false; Shot.transform.LookAt(Player.transform.position + Vector3.up * 1f); Shot.GetComponent <Rigidbody>().velocity = Shot.transform.forward;//(Shot.transform.position - Player.transform.position).normalized * Time.deltaTime * 18f; //Shot.GetComponent<Rigidbody>().velocity.Set(Shot.GetComponent<Rigidbody>().velocity.x, 0,Shot.GetComponent<Rigidbody>().velocity.z); Shot.GetComponent <Rigidbody>().velocity *= 10f; Shot.AddComponent <Destroy>(); } else if (distance < 2) { //Melee attack //Debug.Log("Melee!"); projectile_hits = NumOfRangedHits; Sporeling.SetDestination(prevLoc); NextEngagement = Time.time + ComboInterval; } else { Sporeling.SetDestination(Player.transform.position); } }