Search Unity

Camera follows path

Discussion in 'Scripting' started by Predster, Jul 31, 2008.

  1. Predster

    Predster

    Joined:
    Sep 11, 2007
    Posts:
    145
    I'd like to create an fps-type game where the player (camera) is in a mine car going down a track. The player could move forward and backward, and there would be branches in the track where the player would choose which path to follow.

    Basically, I'd need to have a rigidbody follow some sort of path, and be able to CHOOSE A DIRECTION at branch points--which is the problematic part. I'm not sure what the best way to do this is. I've read a lot about pathfinding on the forums, but it is all related to AI, and I don't know if it would work.

    Would setting up waypoints work? Does anyone have an idea how to go about solving this problem?
     
  2. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
  3. Predster

    Predster

    Joined:
    Sep 11, 2007
    Posts:
    145
    I've checked that out, the copter demo is sweet! My problem is that I don't know how script/construct my scene to allow the user to choose a direction at the branch point of a path. That project has a path with no branch points.


    Edit: I can't seem to get the car demo to play--does this one allow you to choose directions on the path?
     
  4. Proto

    Proto

    Joined:
    Aug 20, 2007
    Posts:
    79
    What it you made a hierarchical path mesh?

    Code (csharp):
    1.     /aa
    2. a-- -- ab
    3.     \ac
    4.  
    You could recursively activate only branches that are relevant. I see a couple of methods discussed on the forum for object path following.