Search Unity

How do I create a passenger-like script on the bus?

Discussion in 'Scripting' started by ErikMartins, Mar 15, 2017.

  1. ErikMartins

    ErikMartins

    Joined:
    Oct 28, 2016
    Posts:
    49
    Can someone help me understand how to create a passenger script entering and leaving the bus like this
     
  2. ErikMartins

    ErikMartins

    Joined:
    Oct 28, 2016
    Posts:
    49
    ?????????????????????? help???
     
  3. lordconstant

    lordconstant

    Joined:
    Jul 4, 2013
    Posts:
    389
    You would need a few scripts from my perspective:

    One for the bus - Holds a list of seats that contain an empty gameobject for its location and who its occupied by. Then allocate seats accordingly as passengers come and go.

    One to give to the passenger - This will direct them to their seat, personally I would create some waypoints in the bus to act as a spline then work out the seats closest position the spline. Then just get the passenger to follow the spline to their seat.

    If you want to have passengers waiting at stops, queueing to enter, waiting for stops etc you may want to look into behaviour trees.
     
  4. ErikMartins

    ErikMartins

    Joined:
    Oct 28, 2016
    Posts:
    49
    Could help me create I have no idea where it starts because I have never done such a script and I am willing to learn.
     
  5. lordconstant

    lordconstant

    Joined:
    Jul 4, 2013
    Posts:
    389
    Start writing something and post on the forums when you get stuck.

    All you really need to do to have a character be on the bus is to set their position to a seat, lock any movement control on them and child them to the vehicle.
     
  6. buluthanakpinar34

    buluthanakpinar34

    Joined:
    Nov 18, 2017
    Posts:
    2
  7. buluthanakpinar34

    buluthanakpinar34

    Joined:
    Nov 18, 2017
    Posts:
    2
    how can I do it




    are there any sources