Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Script doesn't continue when i dont hit anything with raycast2D

$
0
0
So yeah. Maybe its just me thats tired or something. But in this code i've made here there is a wierd error(null reference exeption). `public function Slash(){ var hit: RaycastHit2D = Physics2D.Raycast(transform.position, facingDir, SlashRange); if(hit.transform.tag == "Enemy"){ //I cant attack when the raycast doesnt hit anything.... Debug.Log("I hit the enemy"); }else{ Debug.Log("Didnt hit anything...."); } anim.SetTrigger("Slash"); yield(WaitForSeconds(AttackTime)); anim.SetTrigger("Continue"); } Please help.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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