spawning traffic

allc1865allc1865 Member, PRO Posts: 777
Hi. I'm making a racing game where there will be traffic coming in and out. I've looked, but I couldn't seem to find a tutorial to help me fix this. I want the traffic to come in and stop at a certain point, then continue driving again.
Is there any way to do this? Thanks.

Best Answer

  • BellowBellow Bartender Posts: 227
    Accepted Answer
    try this :

    give this cars move or make waypoint for move and put another actor where you want to stop. and create a rule with your car actor, when collide that that stop actor put timer change movebla or valicity or move or speed i dont know which do you want to use to 0 for 3 sec or how much time you want. put else change valicity or whatever same number

Answers

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291
    edited October 2013
    @allc1865, There are a couple ways to that pop into my head. Try using the "Move To" and after it is where you specified set a timer and once the timer goes off have it move again to the next destination. Also maybe try using the "Interpolate" and after it is where you specified set a timer and once the timer goes off "Interpolate" to the next destination. Just a couple of ideas that popped in my head. If you can show some screen shots or something so we can get a visual of how your game works then we can give you a better idea.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited October 2013
    I attempted this but didn't have much luck slowing down the traffic due to there not being really easy ways for one actor to know the position of all of the other actors i.e. the traffic can't easily tell if there's other traffic cars so far in front, and if so slow down. I tried using multiple collision actors attached to each car but it got laggy.

    http://www.kevincross.co.uk/work-in-progress/project-ida/project-ida-traffic-and-a-speed-dial

    I gave up, but still have the files if you think you might be able to salvage something from it.
  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291
    @KevinCross, don't know if you tried this but throwing it out there. What if you have an invisible actor that is constrained to the cars and sticks off the back of them. When a car coming up behind a car collides with the invisible actor then it slows down or changes lanes or does what ever you want it to do. Just a thought and if you already tried that than bi-golly look at you go! LOL
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited October 2013
    @KillerPenguinStudios, that's exactly what I did, only I needed more than one actor on the front. I wanted 2 or 3 so that they'd break/slow down at different speeds/times, i.e. a car going really slowly won't slow down if a car in front hits the first collision detector which is 200-300 pixels in front. Every traffic car had 3 attached to them but they often misfired when detecting a collision if they were moving too fast and it started to become noticably laggy.

    It became obvious that it would only get worse when I start adding actors to the sides and back of each car too.
  • allc1865allc1865 Member, PRO Posts: 777
    @KillerPenguinStudios, This will be traffic and they will have to drive through a maze, so I will have to set up right and left turns. Wasn't sure how to accomplish that. Does what you mentioned allow my cars to turn left & right?
    Thanks.
  • allc1865allc1865 Member, PRO Posts: 777
    @KevinCross, I wasn't able to locate the project files. Is it a link that i click to download?
    Thanks! :)
  • allc1865allc1865 Member, PRO Posts: 777
    @Bellow, that's what I was thinking, but as Kevin Cross said, I don't this one car would know that another car has stopped.
  • allc1865allc1865 Member, PRO Posts: 777
    think*
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    The project files aren't attached to the blog. I should have them at home on my Mac so will send them over later when I finish work.
  • allc1865allc1865 Member, PRO Posts: 777
    Okay, thanks :)
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Here you go

    Each car has three collision detecting actors attached to them (with an alpha of 0.2 for testing purposes). It uses a table to keep track of every single traffic car position which is how the three actors are constrained to each car. The table is also used to send a signal back to the correct car when the collision detecting actor collides with another car. It kind of works when the traffic cars are moving slowly but it often misfires.

    To accelerate the white car press and swipe upwards, and swipe down to decelerate.

    Like I said I gave up on it, so feel free to take whatever you find useful from it, if anything. I don't know how differently I'd do it if I were to ever try again.
  • allc1865allc1865 Member, PRO Posts: 777
    @KevinCross, Thank you for the file. I'll pick it apart! :)
Sign In or Register to comment.