Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is it possible to know if the Ray has reached the Ray

Discussion in 'Scripting' started by denis-andreevich, Mar 18, 2019.

  1. denis-andreevich

    denis-andreevich

    Joined:
    Aug 21, 2016
    Posts:
    50
    If I put two Ray in different directions from the center of the game object A and on the other side there is a game object B also with two Ray, can I determine the means of C# to determine whether these two Ray crossed or not? Approximate visualization of what I'm talking about in the picture below.

    upload_2019-3-18_9-18-35.png
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    Raycasts only make contact with colliders. You could extend the length of the raycasts and if they hit something, check which side of the object it has hit. You can do that by taking the normal from the hit and comparing the angle of it with the normals of the object which was hit.
     
    denis-andreevich likes this.