Deer moving backwards.
#1

I started writing a deer hunting system today (Well, some of it is based on this: http://pastebin.com/T7AyH6sQ) but their movement is a bit buggy. Most of the time they're moving at the right direction but sometimes they're going backwards. How to fix that?

pawn Code:
func LiigutaKits(id)
{
    new Float:pos[3], Float:randpos[3], Float:speed = 3 + random(3);
    StopDynamicObject(kitseobjekt[id]);
    GetDynamicObjectPos(kitseobjekt[id], pos[0], pos[1], pos[2]);
    if (random(2)) randpos[0] = pos[0] + 10 + random(10);
    else randpos[0] = pos[0] - 10 - random(10);
    if (random(2)) randpos[1] = pos[1] + 10 + random(10);
    else randpos[1] = pos[1] - 10 - random(10);
    MapAndreas_FindAverageZ(randpos[0], randpos[1], randpos[2]);
    if (floatabs(randpos[2] - pos[2]) > 2) return SetTimerEx("LiigutaKits", 0, false, "i", id);
    new Float:angle = angle = atan2(randpos[0] - pos[0], randpos[1] - pos[1]);
    if ((randpos[0] - pos[0]) < 1 || (randpos[1] - pos[1]) < 1) angle += 180;
    SetDynamicObjectRot(kitseobjekt[id], 0, 0, angle);
    MoveDynamicObject(kitseobjekt[id], randpos[0], randpos[1], randpos[2] + 0.4, speed);
    return 1;
}
Reply


Messages In This Thread
Deer moving backwards. - by kristo - 04.06.2014, 11:39

Forum Jump:


Users browsing this thread: 1 Guest(s)