SA-MP Forums Archive
Rotating an attached object - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Rotating an attached object (/showthread.php?tid=404800)



Rotating an attached object - Nonameman - 04.01.2013

Hey,

I'm working on a GPS script, it's nearly finished, but I had to stop working on it beacuse of an annoying problem:

My base idea is when a player uses the /gps cmd in a vehicle, it creates an arrow object, which will be rotated when the global position calculator timer ticks. When that happens, it attach the previously created object to the vehicle with the calculated angle, based on the target destination. The first object attach works, but then the re-attaches doesn't.

I tried it without attaching, too, with SetObjectPos() and SetObjectRot(), but the arrow object doesn't stay at the correct position while the vehicle is moving and it looks bad.

Can you give me some tips, how to solve this problem?

Thanks
Nonameman

EDIT: Solved


Re: Rotating an attached object - mineralo - 04.01.2013

https://sampforum.blast.hk/showthread.php?tid=219539


Re: Rotating an attached object - Nonameman - 04.01.2013

Yes, he do it like me, re-attaching the object, dunno why it doesn't work in my script.

pawn Код:
forward CalculateGPSRotation();
public CalculateGPSRotation()
{
    new Float:ang = -1;
   
    for (new i = 0; i < GetMaxPlayers(); ++i)
    {
        if (i != INVALID_PLAYER_ID && PlayerGPS[i] != -1)
        {
            ang = GetPlayerFacingAngleFromObject(i, GPSDestination[i][0], GPSDestination[i][1]);
            AttachObjectToVehicle(PlayerGPS[i], GetPlayerVehicleID(i), 0.0, 0.0, 1.0, 0.0, 90.0, ang);
        }
    }
}



Re: Rotating an attached object - mineralo - 04.01.2013

download that gps and use that gps rotation, I think its will help you


Re: Rotating an attached object - Nonameman - 04.01.2013

There's no problem with my rotation calculator algorithm, checked it many times, the angle is correct, the attaching is the problem.


Re: Rotating an attached object - mineralo - 04.01.2013

maybe to try to attach every time with rotation to avoid this problem?


Re: Rotating an attached object - Nonameman - 04.01.2013

Solved.