Rotating an attached object
#1

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
Reply
#2

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

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);
        }
    }
}
Reply
#4

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

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

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

Solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)