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

Detect collision with raycast

$
0
0
I need to be able to detect if an enemy is collided with the SphereCast and if so add that enemy to an an Array. My problem is that the counsel gives me an error saying "collided is not a memeber of unit RaycastHit. var enemysInRange = new Array(); function Update () { if(Physics.SphereCast(transform.position, 50, transform.forward, hits, 0.1)){ Debug.Log(hits.collider.tag); } } function OnCollisionStay(collided : Collision){ if(hits.collided.tag == "Enemy"){ enemysInRange.Push(hits.gameObject); Debug.Log("Unit Pushed"); } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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