Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. 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,395
    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,395
    You can use Vector3.Angle to do that.