Creating race spawn positions.
#1

Hello,

I'm working on a new race game in my server, but the problem is when 5 or more players join the race they will get fucked up at the spawn, so I made the next thing, but it is not working correctly;

I made a function that spawns each player at another positions like the following image is showing you.


Now I got the position of player1, my system is creating the other positions by adding coords, but this is only working on 1 map, when I load another map it will not work correctly because the cars having another angle, so when I add some numbers to the X and Y they are not getting in a line like it should, I know why this is but I dont know how to fix it, So my questions is, can someone show me a calculation that returns a positions near it, so something like,
GetNextPositions(currentx,currenty,currentangle,di stance = 3.0);

And this will create a positons near it.
Reply
#2

taken from my object editor (for rotating multiple objects around the first one (like a pin-point)) - iam sure it will work on vehicles, too:
Код:
ObjectX[o][0]=floatadd(BasisPosX,RadiusX*floatsin(Angle,degrees));
ObjectY[o][0]=floatadd(BasisPosY,RadiusY*floatcos(Angle,degrees));
...all you need, is to use your StartX, StartY position, and apply a different radius (for cars' width and lenght), and instead of objects, place vehicles ^^
you might need to add 90 degrees, or swap the sin with the cos function in order to let the vehicles face the right direction...
Reply
#3

Ok thanks, I'm not skilled at all when it comes to floats and calculations,
So how should I modify your calculation when I have for example a car with the following coords;
X = 1200.00000
Y = 600.00000
A = 80.0000

Should be nice if you can show me how to do that.
Reply
#4

consider your first cars' position as the basis, its the "offset". the relative coordinates (the output from the sin/cos transformation) gets added to the basis then.
if you consider an angle of 0° (as above in your example),then
pawn Код:
new Float:Angle=0;
new Float:OffsetX=4*floatcos(Angle,degrees);//offsetx = cars width
new Float:OffsetY=4*floatsin(Angle,degrees);//and y = its lenght
will return 0 for the Y-transformation (drive 0 units forward to north), and
Radius* X for sliding the second car to the right (east in this case), Radius units.

if you take 45 degrees now (facing north east), then its easy to imagine that the second car (on the right of the first one) will be placed more into the south+west direction, and THATS where you need to care for the players'position index (like 3 columns, 10 rows for 30 players on a thin road, or like 5 columns and only 8 rows on a broad highway).
anyways, after adding them together...
pawn Код:
X=X+OffsetX;
Y=Y+OffsetY;
...you should use the heightmap plugin for getting the optimal z-coordinate of the starting point.
when i scripted a similar system, i just spawned the players on a big circle around the starting position, indeed some vehicles got spawned inside houses, so they fell down...

ok, long story short: good luck at testing, feel free to respond if somethin g (doesnt) work as expected ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)