sergeyols
Умник
Использовал вот этот плагин для передвижения актеров. Все бы хорошо но только вот анимация почему-то не двигает актера, он стоит на месте и не поворачивается.
Вот строка с вызовом анимации:
Как видно анимация может быть или "WALK_civi" или "RUN_civi".
Так в чем проблема, почему он топчется на месте? Ведь даже в этой функции есть параметры предусматривающие его перемещение:
Вот строка с вызовом анимации:
Код:
ApplyActorAnimation(actorid, "ped", animAndSpeed[action][animation], 4.1, 1, 1, 1, 0, 0);
Так в чем проблема, почему он топчется на месте? Ведь даже в этой функции есть параметры предусматривающие его перемещение:
Код:
lockx If set to 0, the actor is returned to their old X coordinate once the animation is complete (for animations that move the actor such as walking). 1 will not return them to their old position.
locky Same as above but for the Y axis. Should be kept the same as the previous parameter.
Код:
#define IsActorMoving(%0) actorMoving[%0]
new actorTimers[MAX_ACTORS];
new bool:actorMoving[MAX_ACTORS];
enum animData {
animation[10],
Float:speed
}
new animAndSpeed[2][animData] = {
{"WALK_civi",1.5357},
{"RUN_civi",3.7}
};
forward MoveActorToPos(actorid,Float:x,Float:y,Float:z,action);
forward StopMoveActorToPos(actorid,Float:x,Float:y,Float:z);
stock Float:GetDistanceFromActorToPoint(actorid,Float:x,Float:y,Float:z) // Get the distance between an actor and specified coordinates
{
new Float:ax,Float:ay,Float:az;
GetActorPos(actorid,ax,ay,az);
return floatsqroot(floatpower(ax - x,2) + floatpower(ay - y,2) + floatpower(az - z,2));
}
stock IsActorInCube(actorid, Float:x, Float:y, Float:z, Float:edge) // Additional function to check an actor position to point, currently no need
{
new Float:tx,Float:ty,Float:tz;
GetActorPos(actorid,tx,ty,tz);
tx = (tx-x);
ty = (ty-y);
tz = (tz-z);
if(((tx <= edge) && (tx >= -edge)) && ((ty <= edge) && (ty >= -edge)) && ((tz <= edge) && (tz >= -edge)))
{
return true;
}
return false;
}
stock SetActorFacingPos(actorid, Float:x, Float:y) // This function allows you to change the actor's face turn to the coordinates
{
if(!floatcmp(x, 0.0) && !floatcmp(y, 0.0)) return 0;
static Float:ax, Float:ay, Float:az;
GetActorPos(actorid, ax, ay, az);
az = atan2((y-ay), (x-ax)) + 270.0;
if(az>360.0)az-=360.0;
return SetActorFacingAngle(actorid, az);
}
public MoveActorToPos(actorid,Float:x,Float:y,Float:z,action) // This function allows you to move the actor's to the new position
{
if(0 > action > 1) return print("Error, incorrect value in the function MoveActorToPos argument action");
KillTimer(actorTimers[actorid]);
ClearActorAnimations(actorid);
actorMoving[actorid] = true;
SetActorFacingPos(actorid, x,y);
ApplyActorAnimation(actorid, "ped", animAndSpeed[action][animation], 4.1, 1, 1, 1, 0, 0);
actorTimers[actorid] = SetTimerEx("StopMoveActorToPos", floatround((GetDistanceFromActorToPoint(actorid,x,y,z)/animAndSpeed[action][speed])*918), false, "ifff", actorid,x,y,z);
return false;
}
public StopMoveActorToPos(actorid,Float:x,Float:y,Float:z) {
KillTimer(actorTimers[actorid]);
SetActorPos(actorid,x,y,z-0.1);
ClearActorAnimations(actorid);
actorMoving[actorid] = false;
return false;
}
