Announcement

Collapse
No announcement yet.

[WIP] Traffic System | Maybe Marketplace

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [WIP] Traffic System | Maybe Marketplace

    Update (21.04.15 | 13:50):

    Added Showcase video to the Screenshot section.

    Today i worked on the CarAI itself. I added a state system and started with the avoidence. It now stops
    as soon as i finds another car that is in front and active (not active means it is parking and the AI better drives around it).

    It still needs a lot of work but i'm happy with it for now.

    PS: The first car that arrives and drives into the stairway is already fixed. I forgot to clear the shortest path array, so it wanted to drive to
    the next node which was the first node of one of the other cars. (Video)

    Small Update (19.04.15 | 17:58):

    Ok, i found out that i can make custom events callable in the editor. So now you can easily add and delete new nodes
    by just click on an existing node and clicking the specific button. AWESOME isn't it?


    Hey party people,

    so yesterday i started working on a little fun project. My other current project is getting way to big for me and i need a break from it.

    That's why i started creating a traffic system! The first goal is, to design it similar to GTA, where cars follow the best route to there destination
    and avoid other cars, react to traffic light etc.

    I started by creating a node system and implementing the Dijkstra Algorithm to find the shortest path.

    For now there are only picture, because i am not happy with the video i recorded. Will need to rerecord this.
    I will place the screenshots at the end of the post.


    Features right now:

    You are able to create nodes and connect them (by hand for now). Then you can select an AI Car and give him one node as his target node.
    Then he will ask the system to calculate the shortest path for him and starts driving.

    The car is very slow for now, because i didn't want it to break out of a curve.

    The nodes themself are actors and they will contain a lot of information.


    Features planned:

    Regarding the traffic system:

    I want to have an easier way to place the nodes. At the moment it is a pain to create a new array entry for one of the possible next waypoints
    and search for the name (with almost 90+ nodes). I want to be able to directly say "create me a new node connect to the selected one".
    Maybe i can use Blutility for this, but right now it seems broken, because the buttons for the functions don't show up.

    The nodes will contain information like "Parking Lot", "Traffic Light", "Suggested Speed to drive", etc. So that a node can be modified to be
    a traffic light and manage a crossway with other connected nodes. Or as a parking lot to be a destination where a person leaves its car.

    This means i will need to implement a few road signs, so that the traffic won't collapse.


    Regarding the cars

    Right now they only follow the path with a specific speed and depending on some numbers, steering and slowing down/getting more speed.
    I just pushed in some numbers so that i can test the system. I want to have the car calculate its own speed for a specific distance to a new node
    and also hitting the brake if it would be too fast to take the turn. Also, if a given node has custom values, override the car ones with these.
    Because maybe you have 2 nodes in a small distance, but you don't want to loose any speed.

    In the future, the cars should stop if something is infront of them, honk if it is a person and try to drive around it, if it is an obstacle that isn't active.
    Like a broken car. Also stop behind other cars, so that they don't crash into each other.


    What can i use this system for?:

    Yeah that's a good question. If you are creating a city simulation, it would be a good thing to have this. Also if you want to make GTA5 (please not only because i just said so), you can use this.
    But it can also be used for RTS games. If you have a system where buildings are connected through roads and the delivery car is only allowed to move on these, then it
    would be good to have this, so that a car can calculate the shortest path to a building. You could then disable the cars collision check, so that they can move through each other.


    Future plans:

    I don't really have future plans for this. It is a fun project of course, because i don't need this system for my own project. It just happened to be interesting
    to implement it in UE4 while playing GTA5 the last few days.

    If a lot of you say "OH MY GOD I NEED THIS", then i will think about putting this on the market for 10-20€ (depens on how much time it would take me to finish).


    Screenshots:





    Green spheres indicating the path that the system gave the car:



    Showcase Videos

    Last edited by eXi; 04-21-2015, 07:54 AM.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    #2
    Small update:

    I reworked the car a bit. Now it will try to hold the speed that the node he passed gave him and also slow down if he is moving towards
    a traffic light that is yellow or red.

    And yes, i added traffic lights that are working quite well. The car stops at red and continues driving when the traffic light goes green again.

    At the moment the traffic light contains 2 lanes and a custom amount of traffic light street nodes. So a traffic light is more kind of controller
    for the nodes that change color and tell the car to start driving again. I guess with this i can extend the traffic lights easily, but i need to
    filter the case where i only have 1 lane with traffic lights. A simple array check will do so i guess.

    I also worked on the Blutility functions to easily create new nodes that are connected to the parent node. It is a bit broken, because
    child classes can see the function, but they can't use them. And spawning the child class in the parent class causes an annoying error in BP.
    It doesn't give an error while compiling, only when starting. And when i ignore the warning, it compiles anyway...




    Picture shows the small cubes with colors. Just a simple test to display the colors of the traffic lights. They would go from red&yellow to green
    in the next frame i guess. The blue car is mine, so ignore that

    Last edited by eXi; 04-20-2015, 06:14 PM.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      Nice Work Exi, this is something I have on my radar to learning in the next few months once I finish working on the city's art work.

      Comment


        #4
        Oh my god i need this!

        Comment


          #5
          Hey there,

          glad you two like it so far.

          Update:

          Today i worked on the CarAI itself. I added a state system and started with the avoidence. It now stops
          as soon as i finds another car that is in front and active (not active means it is parking and the AI better drives around it).

          I made a small soundless video to showcase the system so far.

          It still needs a lot of work but i'm happy with it for now:

          PS: The first car that arrives and drives into the stairway is already fixed. I forgot to clear the shortest path array, so it wanted to drive to
          the next node which was the first node of one of the other cars.

          Last edited by eXi; 04-21-2015, 07:54 AM.
          Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

          My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
          (Including 100+ Pages Multiplayer Network Compendium to get you started.)

          Comment


            #6
            Originally posted by eXi View Post
            Today i worked on the CarAI itself. I added a state system and started with the avoidence. It now stops
            as soon as i finds another car that is in front and active (not active means it is parking and the AI better drives around it).
            Looks like the state system and avoidance works well.

            Comment


              #7
              Originally posted by X.E.R.T. View Post
              Looks like the state system and avoidance works well.
              Yes, but only the front. The AI behaves differently based on its state. For example, it stops the car if the state is "Waiting".
              And i use a method "DetermineState" which sets the state based on bools. Like "bIsWaiting" or "bIsWaitingAtTrafficLight".

              That's a pretty easy setup and works well. The hard part will be the "drive around an obstacle" part, since i need multiple
              line traces to check where an obstacle is and combine some of them to make sure that the AI knows if it can pass forward
              or needs to drive backwards first.

              But that's a funny thing to create, so i'm looking forward to it!
              Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

              My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
              (Including 100+ Pages Multiplayer Network Compendium to get you started.)

              Comment


                #8
                This looks pretty interesting, looking forward to seeing the final system and how others integrate it in their projects if you place it on the marketplace. Keep it up. =)

                Simulacrum Game | Play The Alpha | Caldera Entertainment | Twitter | ArtStation

                Comment


                  #9
                  Yes... this would be very useful in Architectural Visualization for Normal City Traffic Simulation
                  Forgive me; for poor English language

                  Comment


                    #10
                    Originally posted by cadviz View Post
                    Yes... this would be very useful in Architectural Visualization for Normal City Traffic Simulation
                    Yeah exactly something like that, where a user or dev doesn't want to think about how the car reaches the target. It just HAS to reach it
                    and it should look like a normal traffic.

                    Or you just build GTA6 x)
                    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

                    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
                    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

                    Comment


                      #11
                      Originally posted by eXi View Post
                      Yeah exactly something like that, where a user or dev doesn't want to think about how the car reaches the target. It just HAS to reach it
                      and it should look like a normal traffic.

                      Or you just build GTA6 x)
                      how is this coming bro?
                      Interested in having someone review your game? want to do an interview on it?

                      This check out this website.

                      Working on a game as well.

                      Comment


                        #12
                        This is a very exciting system. I'm eager to see it released!
                        DO contact me with questions about Blueprint or other Unreal features! I don't bite! Or charge money! Just press that blue Skype button and fire away.

                        Project Culverin - Open Ended First Person Shooter

                        Comment


                          #13
                          Hey there,

                          till now i had no time to work on it. The tutorials and streams cost me alot of time, but i will
                          work on it as soon as i find time.

                          The next step is to get the Car AI to avoid a lot of stuff, like parking cars, wrong driving other cars etc.

                          I will keep this updated as soon as i get to it.

                          Right now i am just working on a quick community project for multiplayers things like Scoreboard, Groups etc.

                          Ahhh so much to do xD
                          Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

                          My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
                          (Including 100+ Pages Multiplayer Network Compendium to get you started.)

                          Comment


                            #14
                            That's pretty cool! Living city ftw!
                            Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-Source)

                            Comment


                              #15
                              Wow, even parking? I can't think of any game that actually has parking as part of the traffic system. That's awesome.
                              DO contact me with questions about Blueprint or other Unreal features! I don't bite! Or charge money! Just press that blue Skype button and fire away.

                              Project Culverin - Open Ended First Person Shooter

                              Comment

                              Working...
                              X