Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Player cannot destroy enemy

$
0
0
I have a game in which my main character "dashes" which triples their movement speed and allows them to destroy enemies. Player Code: //Starting Dash Coroutine. if (Input.GetButtonDown("Fire1")) { if (timeStamp <= Time.time) { StartCoroutine(Dash()); } } } public IEnumerator Dash() { isdashing = true; normalspeed = dashspeed; yield return new WaitForSeconds(dashtime); normalspeed = speed; timeStamp = Time.time + coolDownPeriodInSeconds; isdashing = false; } Enemy Code: public Movement player; public void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player" && player.isdashing == true) { Destroy(gameObject); } } However, the player does not destroy the enemy. Collision detection works fine, both with other objects AND with the enemy (the player just collides/ bounces off of them. What is the problem with my code?

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>