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

Object follow raycast line?

Discussion in 'Scripting' started by gioworks, Jan 16, 2013.

  1. gioworks

    gioworks

    Joined:
    Oct 12, 2011
    Posts:
    138
    Can i make object to follow raycast line, like a road path...?



    Uploaded with ImageShack.us


    Green Objects are 1 car following selected path...



    Uploaded with ImageShack.us

    This is my traffic network example. (I know it is wrong example, but i just did it ti show what i mean)
    Node 1 >> Node2 >> Node3 >> Node4...
    Is is possible to make object to follow raycast line from Node1 to Node2?
     
    Last edited: Jan 16, 2013
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,513
    You say raycast, but you speak nothing of actually performing a raycast.

    Why even use a raycast in that example. You appear to have nodes, and you know the nodes locations. A line segment can be defined as two points (its beginning and end), and yes you can follow a line segment.

    There are numerous ways to follow a line.