Hello Everyone. How do i get an object to follow a drawn line. For instance - i have a car that i want to follow a line which branches a t different points. what i want it to do is follow the line to the branch then pick which direction to go in before following the line again.
If the line is already drawn, then this is easy, but if you are drawing the line, then I too need to know the answer to this question as it could be the answer to making a smooth non-dotted line without the use of extensions. And that will benefit everyone who wants to put drawing in Flash or whatever else that probably isn't compatible with extensions.
Anyway, if the line is already there, you can use the default path movement (more than one if necessary).
Or if you prefer a more custom style, just use a bouncing ball movement and put all its settings at 0, then in the event editor set its speed and direction to what you want. To make it stop simply tell it to stop when the "GO" button is not pressed and the player active is overlapping a stop block, or when it's position is x and y are both equal to the x and y of a node in the line.
Repeat while "GO" is pressed --> set movement speed to 50, set direction to 0.
Yea ... If I confused you, (I usually do confuse people unwittingly), just post a link up here or send the mfa to my email and I'll have a look at it to see what can be done. I imagine that it's probably the more complicated thing, in which case I'd have to say that I'm sorry but I'm in the same lifeboat as you so cannot be of much assistance.
Edit: I should specify a bit more: .. you can switch movement schemes based upon position i.e. if x > pos1 and x < pos 2 and y > pos 3 and y < pos 4 then set direction to random function thing or specific direction (depending on what you're trying to do. Or open one movement group while closing another at a certain spot on the track. There's lots of things you can do for this really.
Or if overlap a hidden active, or you could even use one of those draggable area testing boxes and you can set the movement to add to the direction every N ticks or however you'd like it to react. I'm not entirely sure what the exact thing is that you need really.
Are you having the computer controlled cars follow the player controlled car's "invisible line" that it leaves behind with random twists and turns (I don't know how to do that) or just having the computer controlled cars follow a set pattern and want some random turns thrown in? ... Or is it for the player controlled car (easiest of all)?
Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?
I'd start by creating "node" objects where the paths branch, which would contain a list of possible path choices in one or more alterable value(s) / string(s).
How you handle travel between the nodes will depend on the type of line - are we talking straight, wiggly, or what?
Is it racecar AI, or traffic AI for a game like GTA?
It's for traffic AI. I need it to handle large volumes of traffic all independant from one another but i also need to be able to stop the car at traffic lights and such and also be able to take control of it. hmmmmm....
Sounds like a huge undertaking now i have written it out like that.
being able to make a fully articulated lorry would be cool aswell if someone knows how.
Positional Testing is your Friend. I believe it's how they do it in the real GTA series.
If on this side of the traffic light and looking toward the light, but not too far from it, and light is red, Stop vehicle.
You can use a range of positions with greater and less than to check for that.
You'll probably need to keep track of the x and y position with counters or alt variables and if those values check out, (remember the x y greater less than range testing method)
(in relation to your actives of course, then all you would need to do is place the actives, whereas if you do it by normal positions alone, you'd have to hard-code every location where you want an event to happen, which makes little sense to do if you have large maps) make vehicle movement event happen as long as not in the vicinity of a red light and within the boundaries of the road sorta thing.
Then you could have a random but rare occurence where there's a crazy driver who veers off the road for whatever reason, and little things like obstacle avoidance codes .... mixing it all together to feel like they are real drivers is the tough part.
Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?
The first 2 GTA games were grid based, which makes things quite a lot easier, as you can store all your information in an array, and use tiled graphics as well.
First, you need to break the map down into square tiles, each of which is the width of a single lane (so you'd need 2 tiles to allow traffic to flow in both directions).
Each tile is assigned a value to define which direction(s) traffic is allowed to move in. In the case of traffic lights, this value would be changed at regular intervals.
Now, you need a way for cars to read the road ahead - fortunately, this is actually quite simple.
For example: If the car is moving from west to east, you can find the array coordinates of the car, and then add 1 to the X coordinate, to get the coordinates of the square directly ahead.
The car then just picks a random direction out of those which are allowed, and behaves appropriately - eg. slows down if about to change direction, or stops if no direction is allowed (eg. at a red traffic light).
If the car is coming up to a T-junction, you also need to check whether it is safe to proceed. You could do this by storing the grid positions of all cars, in an array.
The same would apply if you wanted to allow a right turn on a red light.
The other shortcut GTA takes, is that it doesn't keep track of a city full of cars. As soon a car reaches a certain distance from the player, it is removed. Meanwhile, new cars are being spawned constantly as the player drives along. This should help with reducing slowdown, and will prevent the whole system breaking down when something goes a bit wrong.
Actually moving the cars will be more of a challenge. If you want them to collide realistically with one another, and with the player, you are probably going to have to use a physics extension.
I used to like modding GTA, and would recommend you download GTA1 and Junction25 (the GTA map editor), and then you can see for yourself how it works.
I was going to make a kind of MMO GTA game a long time ago, but never got any further than making some graphics - in case anyone wants some teeny tiny car sprites they are welcome to use mine:
Thanks.
Yeah, as you can probably tell, those graphics weren't all for the same game - I just couldn't be bothered to crop and re-upload a picture with just the cars.
It's too bad I don't have the coding skills to make the game I wanted
n/a
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
25th April, 2010 at 02:51:16 -
Sketchy - That image of all the cars is sooo familiar to me. Did you post it on TDC many years ago? Or perhaps another GTA themed site?
The general idea was for it to be a MMO game, with lot's of players driving around in a GTA-like city.
Unlike in GTA, there'd be no missions, carjacking, combat, etc.
Instead, you could play one of three "roles":
1.) Taxi driver - you would earn money by taking people where they want to go in as short a time as possible, á la "Crazy Taxi".
2.) Street Racer - you would challenge other players to an illegal street race across the city, and gamble your cash or pink slips on the outcome.
3.) Cop - you would chase any players caught speeding, and earn a reward for crashing their cars.
Obviously you could switch back and forth between roles, and any money earned could be used to buy and customize your cars.
I still think it's a pretty neat idea for a game...
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
27th April, 2010 at 08:08:26 -
Thread Hijack!
Sketchy - you should totally make that game! Lacewing is much better than moo and will be able to handle lots of data. I also know a lot more about making online games now too