Hello, Again.
Today i'm here looking for some infromation on creating a GTA Style driving system.
I've searched fo rmy answer and sadly failed to find an answer, Found similare questions, but remain un-answerd.
So if someone can answer me with a understandable answer, im sure it will help many people.
Ok.
I have a Car system, Just a basic one to set a users icon to a car when enterd, then Back to normal when exited.
But the driving system is not what i want it to be.
Im going after a OneFishDown GTA Online - Like system.
It's hard to explain.
If i am driving North, And then go directly South, The car will turn around. Such as turning east, then east again.
Theres usually a Server up on GTA Online, So if you cant understand what im seeking, please check it out and drive the car, and you will se what i am trying to achive.
Thank you.
- Bevan
ID:160715
Jul 30 2008, 8:05 am
|
|
In response to Jeff8500
|
|
Jeff8500 wrote:
Just edit the client/North(), South(), East(), and West() procs accordingly. You should also use the turn() proc for your turning. For example: > client It's kinda sloppy (and just plain terrible!), but I think you should get the picure. The turn() proc turns a direction clockwise by the the second arg (the first arg is the dir). 90 degrees is a right angle, 45 degrees would be...half of a right angle (northeast from north etc.). Hmm, Slightly confusing. Don't know if thats what im going for... I strongly recomend playing GTAOnline and driving a Car to se what i mean :( |
In response to BEVAN
|
|
Well, despite the fact I said accelerate instead of decelerate/brake in client/South(), that's what a typical car game is like (minus pixel movement, of course). Maybe you should look up the walk() proc, as it sounds like that's what you might want?
Accelerate would always move the mob forward in my example, too. So... mob/proc/Accelerate() Or it could make them walk forward constantly with walk()... mob/var If that isn't it, you really need to be clearer. Saying it's like another game is very vague. |
In response to Jeff8500
|
|
Jeff8500 wrote:
Well, despite the fact I said accelerate instead of decelerate/brake in client/South(), that's what a typical car game is like (minus pixel movement, of course). Maybe you should look up the walk() proc, as it sounds like that's what you might want? > mob/proc/Accelerate() Or it could make them walk forward constantly with walk()... > mob/var If that isn't it, you really need to be clearer. Saying it's like another game is very vague. Still, Your code confuses me and i doubt it's not what im looking for. As i've sudgested, you should check GTA Online (Created by OneFishDown) Theres usually a server online, Hosted by Dipstyx if im correct. Well, i'll try to explain clearer. - I have myself a car code i created, To get a user in and out of a car. Th euser can drive the car. (I've added delays to walking, and what not to make the car run faster) But if i turn, it will just turn.. Non-life like. In real life, If you turn a car, it wont just automaticly face that way and move 1 spot now would it? No. Im driving North, I Press Right, My car goes North-East, then East. (So its liek the car is doing a real life turn) and carrys on. Thats what i want. Also, If im driving north, And Decide to go south, On my system, It will go straight down, In real life, it would go - Southeast, South. Like a turn. I need that for every turn a real life car would do. I hope i have explained more, If not, Im sorry but you will have to go Play GTA Online by OneFishDown to se what im talking about, i find this hard to explain, thats why posts made about this thing in the past have died without a helpfull answer. |
In response to BEVAN
|
|
The first code he does does what you want I believe. As for the from North to South, perhaps you could figure out a way to make it so when you're driving north, you can't automatically go south but you'd have to use east and west to turn in far enough to go south.
|
In response to DisturbedSixx
|
|
I tested the first code, and it was totoally not what i want.
If someone just done what i siad, and checked GTA Online, it would explain allot of what i want for my car system :( This is REALLY hard to explain. |
Easiest way to explain what I think you want:
You want to tap a direction key to "set" your intended direction. After setting your intended direction, your vehicle then automatically turns to face that direction, rotating through the facings over time until it is facing in the given direction. (It obviously only does this if the car is already moving forward.) Acceleration is handled independently. What most people were suggesting to you: Press up to accelerate, down to decelerate, left to turn left, right to turn right. I suspect this isn't what you want. How to do it: What you want to do is make your vehicles have a movement loop that runs over and over again. Each "frame" (tick), the loop is run once more, and the vehicle is then moved forward if going fast enough (or not moved at all if the vehicle is not going fast enough). Here I'm assuming you want a tile-based movement system for the cars, instead of worrying about making it considerably more complex and moving them pixel-by-pixel across the screen. If the vehicle's set direction is not equal to the desired direction, it turns towards the desired direction by comparing the desired direction to various degrees of turning from src.dir using the turn() proc. if current direction is not equal to desired direction if desired direction is equal to (turn(180, src.dir)) choose a random direction to turn (or: turn left if on the right side of a street, turn right if on the left side) else if desired direction is in the list {turn(45, src.dir), turn(90, src.dir), turn(135, src.dir)} turn left (in BYOND, 45 is counterclockwise, -45 is clockwise) else turn right Try to enforce a turning delay each time so that cars can't turn on a dime. This works somewhat better if it gets harder to turn the vehicle as your speed increases, so someone going *too* fast will wind up plowing into a wall regardless of the car's turning rate, because there's no control at that speed on city streets. |
In response to BEVAN
|
|
I did check it, and I gave you exactly what you want. You hit the right key, you turn right. You hit the left key, you turn left (clockwise and counter-clockwise respectively). As for south, just don't allow it or use it to brake. Also, if my code confuses you, you should take that source code you have down...
|
In response to Jeff8500
|
|
Jeff8500 wrote:
I did check it, and I gave you exactly what you want. You hit the right key, you turn right. You hit the left key, you turn left (clockwise and counter-clockwise respectively). As for south, just don't allow it or use it to brake. Also, if my code confuses you, you should take that source code you have down... You diddn't give me what i wanted, I tested your code and it was not what i wanted. It does not do what i want it to do. And what do you mean take the source code down? What are you refering to? I can code allot of things, But when it coems to location and direction coding, such as this, im lost. I can, and have made a few games. Bu tthose games do not include the sort of coding knowledge i need for this car system. I feel like you are trying to say i can't code. if so you are sadly mistaken. Many byond users can code different things, and many cant code some things. Not everyone in this community can code every thing, I am quite offender a little, but i'll wait for your reply to se what you ment. |
In response to BEVAN
|
|
Well, sorry for not giving you what you wanted, I tried that driving system out, but it was only about 20 seconds before I accidently went into a doorway with it. Then the car blew up and left me stuck in a doorway blocked by the car salesman. I found it very hard to control, too! Either way, even if I didn't give you exactly what you wanted, you could definitely work with what I did give you. I explained everything in detail. The client/North() etc. are called when a player hits the respective key (North is the up key, east is the right key and so on). turn(direction,degrees) rotates a direction by the amount of degrees you specify in the second arg. A positive number is clockwise and a negative number is counter clockwise. walk() moves a movable atom in a certain direction constantly (walk(movable atom, direction, lag between movements)) and calling walk(atom,0) halts said movement. The parent (..()) of the North() etc. procs call src.Move() towards the north, which in turn calls mob.Move() and so on.
EDIT: And I've seen your code. It's not pretty. In fact, what I saw has massive : abuse and lack of boolean logic. |
In response to Jeff8500
|
|
Jeff8500 wrote:
Well, sorry for not giving you what you wanted, I tried that driving system out, but it was only about 20 seconds before I accidently went into a doorway with it. Then the car blew up and left me stuck in a doorway blocked by the car salesman. I found it very hard to control, too! Either way, even if I didn't give you exactly what you wanted, you could definitely work with what I did give you. I explained everything in detail. The client/North() etc. are called when a player hits the respective key (North is the up key, east is the right key and so on). turn(direction,degrees) rotates a direction by the amount of degrees you specify in the second arg. A positive number is clockwise and a negative number is counter clockwise. walk() moves a movable atom in a certain direction constantly (walk(movable atom, direction, lag between movements)) and calling walk(atom,0) halts said movement. The parent (..()) of the North() etc. procs call src.Move() towards the north, which in turn calls mob.Move() and so on. I appreciate you trying to help, and yes i belive i can work off your code. Thank you. Yet what are you refering to? My source? The only source i have released is my Old Pokemon Life game, Which was a complete mess and the first version. Which im sure i taken down 4 months ago due to people just ripping with no credit given to me. What else are you refering to? Becaue im sure theres no way your able to get that source. I'm no expert coder, Or anything like that. i learn by looking at other sources and Demos and libraries seeing how things work, and i pickup rather bad ways on how to do things i guess. Im not the type who likes to read long books. |
In response to BEVAN
|
|
I'm talking about your other code, for doors. Still, it was made around the same time as your source, so I assume they must be similar.
As for the reading libraries and demos, that's fine if you read the good ones: http://www.byond.com/members/ DreamMakers?command=view_favorite_resources |
In response to Jeff8500
|
|
Jeff8500 wrote:
I'm talking about your other code, for doors. Still, it was made around the same time as your source, so I assume they must be similar. Ah, The Password Lockable Doors. That works, yet can be created in a easier way i assume. And i was new to coding back then, As i first started making a Building game, Which suprisingly got allot of attention than i intended. Anyway, Thank you for that link. I'm sure i'l lbe needing it. And thank's for your help. |
It's kinda sloppy (and just plain terrible!), but I think you should get the picure. The turn() proc turns a direction clockwise by the the second arg (the first arg is the dir). 90 degrees is a right angle, 45 degrees would be...half of a right angle (northeast from north etc.).