Vehicle coordinates and vehicle angle
#1

Hi,


I have Float:X and i'am adding +5.0, but this only works when vehicle face to north if i face to another adding x coordinate +5 give my front that mean i think i have add +5 to Y not to X. I need to make effect only for x axis how calculate vehicle angle and to what coordinate x or y i have to add my value
Reply
#2

PHP код:
new currentveh GetPlayerVehicleID(playerid);
 
          new 
Float:vehxFloat:vehyFloat:vehz Float:z_rot;
          
GetVehiclePos(currentvehvehxvehyvehz);
         
GetVehicleZAngle(currentvehz_rot); 
next time please use ******
Reply
#3

That is not what i need

Код:
new Float:XXX, Float:YY, Float:ZZZ;
    GetVehiclePos( GetPlayerVehicleID(playerid), XXX, YY, ZZZ );
    
    
    CreateDynamicObject( 1215, XXX+0.5,YY,ZZZ, 0.0, 0.0, 0.0 );



That green is vehicle they are same, As you see if i add +0.5 when vehicle angle to north everything is good, but if i face to east in the same direction adds value ,although the machine is already in the other direction, as a result this give my along machine position i need that new position when i add +0.5 will be in left or right side that mean i think i need to change y coordinate, but how to calculate it nice
Reply
#4

By using GetVehicleZAngle and trig:

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);

new Float:vX, Float:vY, Float:vZ, Float:vAngle;
GetVehiclePos(vehicleid, vX, vY, vZ);
GetVehicleZAngle(vehicleid, vAngle);

vX += 0.5 * floatsin(-vAngle, degrees);
vY += 0.5 * floatcos(-vAngle, degrees);

CreateDynamicObject(1215, vX, vY, vZ, 0.0, 0.0, 0.0);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)