Quantcast
Channel: Latest Questions by Wrymnn
Viewing all articles
Browse latest Browse all 131

Raycast2D problems

$
0
0
Hi, Why the following code isn`t working? Vector2 direction = transform.TransformDirection(Vector2.up); RaycastHit2D hit = Physics2D.Raycast(transform.position, direction); if (hit.collider.tag == "Asteroid") { print("Object hit"); } Object is asteroid, the raycast is pointing the right way. Also I tried if (hit.collider.gameObject.tag == "Asteroid") If I write it like this, it completely ignores the other objects. if (hit.collider != null && hit.collider != parentShip) (ship object that this object is on) { print("retarded raycast"); distance = Vector2.Distance(transform.position, hit.point); }

Viewing all articles
Browse latest Browse all 131

Trending Articles



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