01.08.2011, 07:07
oh! Thanks.
Heres a nice function, made based off PgnPunkids (current name?) shark circling include.
It must be used in a timer to successfully circle a object.
To check when it's finished, check if the degree is back to 0 / 360.
Heres a nice function, made based off PgnPunkids (current name?) shark circling include.
pawn Код:
new Float:degree[MAX_OBJECTS] = 0.0;
forward CircleObject(objectid, Float:x, Float:y, Float:z, Float:speed, Float:radius, Float:Cdegree);
public CircleObject(objectid, Float:x, Float:y, Float:z, Float:speed, Float:radius, Float:Cdegree)
{
new Float:X, Float:Y, Float:Px, Float:Py, Float:Temp;
if(degree[objectid] < 360) degree[objectid] += Cdegree;
else degree[objectid] = 0.0;
X = (floatmul(floatcos(degree[objectid], degrees), radius));
Temp = ((radius * radius) - floatpower(X, 2));
Y = floatsqroot(Temp);
if(degree[objectid] >= 180) Y *= -1;
Px = floatadd(x, X);
Py = floatadd(y, Y);
MoveObject(objectid, Px, Py, z, speed);
SetObjectRot(objectid, 0, 0, degree[objectid]);
//printf("[System - Circling Object] - Degree: %f - X: %f - Y: %f - Px: %f - Py: %f", degree[objectid], X, Y, Px, Py);
return 1;
}
To check when it's finished, check if the degree is back to 0 / 360.