25.10.2014, 02:01
(
Последний раз редактировалось Pottus; 25.10.2014 в 04:51.
)
Someone probably has a better way to do this than me but I will try and come up with an idea for you.
Main variables
distance - Distance of object to move
height - Height of object to attain
numframes - Number of frames in sequence
angle - Angle of origin
origin-x - Origin position
origin-y - Origin position
origin-z - Origin position
Calculating x/y/z positions
dist = distance / numframes
I will give you a test script to make sure that worked as expected. There is probably a better way to do this but I will admit I'm actually terrible at trig.
Ok here we go sorry about that
Printing
Result your moveobject frames
Okay now that code seems to work you will need to create a frame generator / playback function I will give the function definitions but no code
Main variables
distance - Distance of object to move
height - Height of object to attain
numframes - Number of frames in sequence
angle - Angle of origin
origin-x - Origin position
origin-y - Origin position
origin-z - Origin position
Calculating x/y/z positions
dist = distance / numframes
I will give you a test script to make sure that worked as expected. There is probably a better way to do this but I will admit I'm actually terrible at trig.
Ok here we go sorry about that
pawn Код:
#include <a_samp>
#include <zcmd>
CMD:testp(playerid, arg[])
{
new Float:ox, Float:oy, Float:oz, Float:angle, Float:x, Float:y, Float:z;
GetPlayerPos(playerid, ox, oy, oz);
GetPlayerFacingAngle(playerid, angle);
new numframes = 15;
new Float:height = 40;
new Float:distance = 20;
new Float:framedistratio = numframes / distance;
new Float:dist = floatdiv(distance, float(numframes));
printf("%f", dist);
for(new i = 1; i <= numframes; i++)
{
x = ox + ((dist*i) * floatsin(-angle,degrees));
y = oy + ((dist*i) * floatcos(-angle,degrees));
z = oz + floatmul(floatsin(floatmul(floatdiv(3.14159265359/framedistratio, distance), i)), height);
CreateObject(1974, x, y, z, 0.0, 0.0, 0.0);
}
return 1;
}
pawn Код:
floatmul(floatsin(floatmul(floatdiv(3.14159265359/2, distance), i)), height);
Код:
0.500000 1.564344 3.090169 4.539905 5.877852 7.071067 8.090169 8.910065 9.510565 9.876883 10.000000 9.876883 9.510564 8.910064 8.090169 7.071067 5.877851 4.539903 3.090167 1.564344 -0.000000
Okay now that code seems to work you will need to create a frame generator / playback function I will give the function definitions but no code
pawn Код:
frameindex = GenerateFrames(numframes, Float:ox, Float:oy, Float:oz, Float:angle, Float:distance, Float:height)
ClearFrames(frameindex);
PlaybackFrames(objectid, frameindex, Float:speed);
forward OnFinishFramePlayback(objectid, frameindex);