Different angles - different pos
#1

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

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

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.
Reply
#4

did you try using GetVehicleZAngle
Reply
#5

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...
Reply
#6

And why would you want to offset it at CreateObject?

Why not just offset it at AttachObjectToVehicle
Reply
#7

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).
Reply
#8

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)