I’m trying to make my Player character dash through specific enemies and don’t take any damage during de dash animation, here is the script:
using UnityEngine;
using System.Collections;
using CnControls;
public class PlayerDash : MonoBehaviour {
private Animator myAnim;
private bool dash = false;
private float dashTimer = 0;
private float dashCd = 0.3f;
public Collider2D[] Coll;
void Start () {
myAnim = gameObject.GetComponent<Animator> ();
}
void Update () {
if (CnInputManager.GetButtonDown ("Dash") && !dash) {
dash = true;
dashTimer = dashCd;
myAnim.SetBool ("Dash", dash);
foreach (Collider2D coll in Coll) {
if (coll.gameObject.tag == ("Enemy")) {
coll.enabled = false;
}
}
}
if (dash) {
if (dashTimer > 0) {
dashTimer -= Time.deltaTime;
} else {
dash = false;
myAnim.SetBool ("Dash", false);
}
}
}
}
Everything is working fine, but when i use dash and collide with a “dasheable” enemy, every “dasheable” enemy don’t inflict damage to the Player(that’s because the condition i use), what conditions should i use to make enemy colliders still being active after i dash the first one, already tryed some options here and nothing seems to work properly