Jump to content

3 cars following one?[yes another question :P]


cokacola

Recommended Posts

hello..again.. I am trying to accomplish something diffrent :P

I have a command, and when you type

/cars [car name]
it creates a car, puts you in it, then creates 3 cars behind you, that "follow" you. First i tried using attachElements...and it was ugly, then I tried using get/setElementVelocity & get/setVehicleTurnVelocity, with a timer, and it was less ugly, but still incredibly weird.

I am guessing I will just be told to do it with bots, but i am entirely un-shore on how to make a bots car follow me everywhere. So if there is another method, what is it?

otherwise, can someone point me in the right direction for accomplishing this with peds?

thank you :)

EDIT:

okay, basicly solved, just had a timer and used get/setPedControlState

would be nice if they just followed me, though, so new question, see, if I hit a post or something, and flip, they go in a diffrent direction to me, so how could I solve that? thank you :)

Link to comment

Okay, thanks, I will try that :)

EDIT:

I just tried set/getVehicleTurnVelocity & get/setVehicleRotation but neather of them worked...if they turn away from me, they still drive away from me.

EDIT 2:

Okay, it works, i just used set/getVehicleRotation & turn velocity on the clientside script, and it told me to upgrade because it was set/getElementVelocity and now it works.

If anyone is interested in me posting the whole working script, just say. I am fine with that :)

Link to comment

setElementParent doesn't do anything like "attachments", all it does is move the position of that element in the element tree.

All you would accomplish with it is destroying the "parent" car (in script, not blowing it up) would automatically destroy the child cars too.

A common use for it would be grouping similar elements - for example you could make a dummy element called "redSpawnpoints" whose parent is a team element, and all that team's spawnpoints are children of it. Then if you needed to access all the spawnpoints in code at some time (say, for respawning), you can then use "getElementChildren(redSpawnpoints)".

Link to comment

Yea, it really doesn't :P

if it made the bots follow me, I'd use it :D

Anyway, they follow me fine, but my main problem is that rather than actually follow me, they just do everything I do, so if 1 hits a wall, they stay behind, and I want them to follow me not just do everything I do, so I looked at slothman's amazing zombie mod, and thought, maybe I should just have it check if they are facing me, then turn, but then, i realized, they'd both go offroad AND hit walls, so ATM, I have no idea what to do, and need pro ped help(hint hint, slothman, your good at bots :P) so, basically, i have No Idea what to do, because, unlike zombies, cars can't just "jump" over walls and continue to follow me, I have tried, and well, I am confused :)

there must be a resource or something that does this right? :P

Link to comment
setElementParent doesn't do anything like "attachments", all it does is move the position of that element in the element tree.

All you would accomplish with it is destroying the "parent" car (in script, not blowing it up) would automatically destroy the child cars too.

A common use for it would be grouping similar elements - for example you could make a dummy element called "redSpawnpoints" whose parent is a team element, and all that team's spawnpoints are children of it. Then if you needed to access all the spawnpoints in code at some time (say, for respawning), you can then use "getElementChildren(redSpawnpoints)".

Actually, I used setElementParent on my vehicles, client-side, and it copied the velocity.

Link to comment
you can make cars act the same as a normal player by warping a ped into it and setting its control state.

That is exactly what I did, but I want them to follow me, not copy me, and its annoying, because I cannot do it without them just hitting walls, fences, poles and whatever else they desire including other peds >.<

Link to comment

The simplest way of doing this would to code a routine where they try to drive to a "point" - accelerate if they're facing towards it, and turn to face it when not. Have this point be the vehicle in front (or just behind that vehicle, to reduce ramming :P)

This is a crude solution however, as you have to handle the fact that cars cannot turn without velocity - not to mention such a solution would easily be thwarted by a wall and will have issues with corners. Having said that, Slothman has dealt with similar issues when making his zombies, so he's your best bet for help.

Of course the near-perfect solution would be both a fully fledged driving AI, that follows a pathing network - this is how Rockstar did it. Unfortunately, MTA doesn't expose access to either (and while it may be possible to expose the pathnodes with some development, certain low-level design choices mean we'll never get access to the AI routines besides someone skilled working on a straight port from the SCM) so unless you have the knowledge and the patience to code an entire vehicle AI yourself, crude solutions may be your best bet.

Link to comment

Vehicle AI shouldn't be that hard, it's just a matter of simulating the presses of the buttons to get the vehicle to follow a path. You can export the paths from GTA and import them in an MTA friendly format - that will let you defined your own paths if you want to use custom maps. Competitive driving - evasion, collision avoidance etc is more challenging though.

Link to comment

I could probably have cars running on a path, but ATM, i want them to follow me, one of my main problems, is the fact that if i go around a corner, they are likely to hit walls when following me, same as now, they follow my every action, but if they fall behind, they meet destiny with the brick wall :/

Link to comment

Well you don't want to give them exactly the same controls you're pressing, you want to give them the controls you were pressing some time ago. This won't work well when you're accelerating or decelerating though.

Link to comment

yea, maybe :P

I noticed that when they follow your exact commands, you can make a squad of hunters, it looked awesome, I even got pictures.

I was disappointed that they could only fire machine guns, and not the rockets(couldn't fire rockets on hydra ether) so I am guessing bots cannot do that? also, special controls(8,2,4,6) do not work with bots, or so I have seen, and I cannot make the hydra go forward for them unless they do, so bots seem to have some issues here and there ^.^

Link to comment
you can make cars act the same as a normal player by warping a ped into it and setting its control state.

That is exactly what I did, but I want them to follow me, not copy me, and its annoying, because I cannot do it without them just hitting walls, fences, poles and whatever else they desire including other peds >.<

who said anything about copying? what's your problem?

by the way the path points are available. http://s000.tinyupload.com/?file_id=128 ... 6183642619

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...