The Daily Click ::. Forums ::. Klik Coding Help ::. Follow a line
 

Post Reply  Post Oekaki 
 

Posted By Message

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
22nd April, 2010 at 12:05:12 -

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.

any ideas??

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
23rd April, 2010 at 05:51:59 -

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)?


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

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 ?

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd April, 2010 at 12:14:15 -

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?

Edited by Sketchy

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
23rd April, 2010 at 14:51:48 -

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.

thanks

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
23rd April, 2010 at 20:09:11 -

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.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

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 ?

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd April, 2010 at 20:56:55 -

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.










 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
23rd April, 2010 at 22:38:01 -

Cheers Sketchy!!!

So much useful info in there. Will look into the Level Editor later

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
24th April, 2010 at 05:05:27 -

I was thinking of doing something like this,

Thanks for the info Sketchy!

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th April, 2010 at 19:58:39 -

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:

Image
http://usera.imagecave.com/adamhawker/mypics.png

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
24th April, 2010 at 21:45:14 -

Those are awesome sketchy!

Wish you wouldve finished that game.

 
n/a

nim



Registered
  17/05/2002
Points
  7234
25th April, 2010 at 01:49:22 -


Originally Posted by Sketchy

http://usera.imagecave.com/adamhawker/mypics.png

Cars? Schoolgirls? Tanks? Spaceships? DRAGONS? Women with their clothes hanging off? I'd love to hear the storyline this game had planned

Amazing artwork though

Edited by nim

 
//

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
25th April, 2010 at 02:11:53 -

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

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
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?

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
25th April, 2010 at 03:39:56 -

Yeah, I posted before, and you gave me lots of good advice

http://www.create-games.com/forum_post.asp?id=191058&s=0
http://www.create-games.com/forum_post.asp?id=191335

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...

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
25th April, 2010 at 14:06:52 -

I was going to make a crazy taxi like game.

I'm prolly going to make my own graphics though.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
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

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
   

Post Reply



 



Advertisement

Worth A Click