cokacola Posted November 30, 2009 Share Posted November 30, 2009 hello..again.. I am trying to accomplish something diffrent 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
Xalphox Posted November 30, 2009 Share Posted November 30, 2009 Get the angular velocity and apply it to the other three? That way, if you flip over, they will too. Link to comment
cokacola Posted December 1, 2009 Author Share Posted December 1, 2009 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
Maccer. Posted December 1, 2009 Share Posted December 1, 2009 Why not just do setElementParent(a, b)? Link to comment
subenji99 Posted December 1, 2009 Share Posted December 1, 2009 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
cokacola Posted December 1, 2009 Author Share Posted December 1, 2009 Yea, it really doesn't if it made the bots follow me, I'd use it 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 ) 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? Link to comment
Dark Dragon Posted December 1, 2009 Share Posted December 1, 2009 you can make cars act the same as a normal player by warping a ped into it and setting its control state. Link to comment
Maccer. Posted December 1, 2009 Share Posted December 1, 2009 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
cokacola Posted December 1, 2009 Author Share Posted December 1, 2009 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
subenji99 Posted December 1, 2009 Share Posted December 1, 2009 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 ) 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
eAi Posted December 1, 2009 Share Posted December 1, 2009 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
cokacola Posted December 1, 2009 Author Share Posted December 1, 2009 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
eAi Posted December 1, 2009 Share Posted December 1, 2009 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
cokacola Posted December 2, 2009 Author Share Posted December 2, 2009 yea, maybe 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
Dark Dragon Posted December 2, 2009 Share Posted December 2, 2009 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
DakiLLa Posted December 2, 2009 Share Posted December 2, 2009 by the way the path points are available Omg! Is this a part of 'peds and traffic' script? Oo Link to comment
cokacola Posted December 3, 2009 Author Share Posted December 3, 2009 O_O There is AlOt of paths in there, I wonder how I could make bots follow them Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now