SA-MP Forums Archive
Different angles - different pos - 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: Different angles - different pos (/showthread.php?tid=348414)



Different angles - different pos - zgintasz - 05.06.2012

Hi guys,

I have this command. It should create object in the same place(at the vehicle's right wheel). But in different vehicle angles, it creates in different pos. Note: if I use AttachObjectToVehicle(look at the commented line) it works perfectly. But I need to do that with CreateObject...

pawn Код:
COMMAND:test2(playerid, params[])
{
    new
        Float:vPos[ 3 ],
        Float:offsetPos[ 3 ],
        obj
    ;
    GetVehiclePos( GetPlayerVehicleID( playerid ), vPos[ 0 ], vPos[ 1 ], vPos[ 2 ] );
    GetVehicleModelInfo( GetVehicleModel( GetPlayerVehicleID( playerid ) ), VEHICLE_MODEL_INFO_WHEELSREAR, offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ] );
    printf( "%f, %f, %f", offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ] );
    obj = CreateObject( 323, vPos[ 0 ] - offsetPos[ 0 ], vPos[ 1 ] - offsetPos[ 1 ], vPos[ 2 ] - offsetPos[ 2 ], 0.0, 0.0, 0.0 );
    //AttachObjectToVehicle( obj, GetPlayerVehicleID( playerid ), offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ], 0.0, 0.0, 0.0 );
    return 1;
}
Thanks guys! Sorry for my bad English...


Re: Different angles - different pos - HuSs3n - 05.06.2012

you need to find the coords for each vehicle and add it in an array


Re: Different angles - different pos - zgintasz - 05.06.2012

Quote:
Originally Posted by HuSs3n
Посмотреть сообщение
you need to find the coords for each vehicle and add it in an array
It's not a vehicle models problem, it's problem with angles(vehicle rotation). The offset doesn't work for CreateObject, but works perfectly with AttachObjectToVehicle. Please, help someone.


Re: Different angles - different pos - HuSs3n - 05.06.2012

did you try using GetVehicleZAngle


Re: Different angles - different pos - zgintasz - 05.06.2012

Quote:
Originally Posted by HuSs3n
Посмотреть сообщение
did you try using GetVehicleZAngle
Wtf, do you know what are you saying? Or you just post counting? I need a solution, I don't know how to use GetVehicleZAngle in this situation...


Re: Different angles - different pos - milanosie - 05.06.2012

And why would you want to offset it at CreateObject?

Why not just offset it at AttachObjectToVehicle


Re: Different angles - different pos - zgintasz - 05.06.2012

Quote:
Originally Posted by milanosie
Посмотреть сообщение
And why would you want to offset it at CreateObject?

Why not just offset it at AttachObjectToVehicle
Using AttachObjectToVehicle I won't do what I want. Don't ask, I just need(it's a secret).


Re: Different angles - different pos - kurta999 - 05.06.2012

I'm not good at math, but try MPProjectPointOnVehicle(..)

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


Re: Different angles - different pos - zgintasz - 05.06.2012

kurta999, thanks for reply. Am I using it right? It doesn't do anything(only prints text in console)

pawn Код:
COMMAND:test2(playerid, params[])
{

    new
        Float:vPos[ 3 ],
        Float:offsetPos[ 3 ],
        Float:res[ 3 ],
        obj
    ;
    GetVehiclePos( playerid, vPos[ 0 ], vPos[ 1 ], vPos[ 2 ] );
    GetVehicleModelInfo( GetVehicleModel( GetPlayerVehicleID( playerid ) ), VEHICLE_MODEL_INFO_WHEELSREAR, offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ] );
    printf( "%f, %f, %f", offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ] );
    MPProjectPointOnVehicle( GetPlayerVehicleID( playerid ), offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ], res[ 0 ], res[ 1 ], res[ 2 ] );
    printf( "%f, %f, %f", res[ 0 ], res[ 1 ], res[ 2 ] );
    obj = CreateObject( 323, vPos[ 0 ] - res[ 0 ], vPos[ 1 ] - res[ 1 ], vPos[ 2 ] - res[ 2 ], 0.0, 0.0, 0.0 );
    return 1;
}



Re: Different angles - different pos - zgintasz - 06.06.2012

kurta999, thanks, I've fixed it! Thank you very much .