View Full Version : car help
killingdyl
06-01-2008, 08:52 PM
im making an rpg game based on really life.im having a little problem with my cars:
1) they are based on motion tweens and i dont want to have to make 100 tweens. is there a way to generate random routes for my car to go.
2) i need them to stop at the cross walks if my character is on it
Thanks
I don't usually use motion tweens for in-game movement, because I know I'm going to want to have exceptions for in-game events, like someone standing at a crosswalk.
You'll need to make basically a map of all the intersections and the paths between intersections. Then each time one of your cars reaches an intersection, it will choose a direction. This map should also include the crosswalks, and if the car is approaching a crosswalk, check the crosswalk's proximity to your character.
Look up graph theory for basically how you'd represent the map of intersections. Each intersection would be connected to 3 or 4 paths, each representing a different direction you could take. Each crosswalk would be connected to 2 paths. Each path would be connected to 2 intersections or crosswalks.
You might want to treat driving on the one side of the road as a separate path from the other side of the road, which will make positioning the cars on the path easier. And then each intersection would have a different entry for each direction the car enters the intersection.
This'll be a pretty elaborate job for something that isn't explicitly a driving game.
killingdyl
06-05-2008, 01:04 AM
i searched google but couldnt find a good tutorial
Okay. Ignore the graph theory. You just need a way to represent what something is connected to. One thing that's nice about treating the two side of the road differently is that the connections can be one way.
It will be made simpler if all the streets are on nice 90 degree angles to one another. That way, you have a limited number of types of turns the cars need to be capable of. (Left, right, straight. Then rotate them to face North, South, East and West)
killingdyl
06-08-2008, 03:56 PM
ok im havent tried it yet but i have an idea, but i dont know if its going to work.
im thinking give the car a var called speed. and when it turns i just have to do some complicated math to see how much to rotate it.
that will work right?
rotation=Math.atan2(y,x)*180/Math.PILearn to love trigonometry. You will use it so much in games.
killingdyl
06-18-2008, 06:42 AM
ok. so far ive gotten the car to run up to the cross walk and slow down and choose a route.
i need help on making a timer so that the car waits until the timer is <= 0 then move again.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.