Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Problem with Raycasting objects

Discussion in 'Scripting' started by Dolke, Jun 15, 2018.

  1. Dolke

    Dolke

    Joined:
    Dec 16, 2016
    Posts:
    37
    Hello.

    I need help about one problem.

    I made script like this


    What I need this script to do is to have array like this and I make example 3 objects,I put their positions in those Vector3 fields and have raycast that checks if I hit one of those objects included in this array,and do the some function.
     
  2. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,118
    You may be far better off using collider triggers to achieve this.
     
  3. Dolke

    Dolke

    Joined:
    Dec 16, 2016
    Posts:
    37
    But how can I check with collider trigger ,am I facing the object I want to interact?
     
  4. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,118
    You can use Vector3.Angle to do that.