![]() ![]() ![]() Method to draw the ray in scene for debug purposeĭebug.DrawRay(transform.position, Vector2.right * laserLength, Color.red) Hit something, print the tag of the objectĭebug.Log("Hitting: " + ) If the collider of the object hit is not NUll RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.right, laserLength) Now let’s see a simple code to generate and debug a ray in our game. The second could be returned only if the first is ignored due to the configuration we applied. If we have 2 consecutive objects only the first object hit by the laser will be returned. It’s very important to notice that this version of the method will report only the first object hit by the laser according to the configuration.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |