Jump to content

Vehicle aim


Anubhav

Recommended Posts

Posted

Is it possible to get vehicle's aim? I din't find any function, please help me to get the functions. I'm trying to create a image there, and I saw this in MTA Battlefield #1/2 server.

Thank you for helping!

Posted
  
createVehicle -- That for create vehicle 
createPed -- That for create driver 
setElementAlpha -- If you want hide driver 
warpPedIntoVehicle -- That for create warp driver into vehicle 
setPedAnalogControlState -- That for control vehicle 
  

Posted
  
createVehicle -- That for create vehicle 
createPed -- That for create driver 
setElementAlpha -- If you want hide driver 
warpPedIntoVehicle -- That for create warp driver into vehicle 
setPedAnalogControlState -- That for control vehicle 
  

Sorry, you din't get what I meant. I meant to get where the vehicle is aiming to FIRE. Like hydra missile aiming.

and Dealman can you give me a small example of it? I'm bad at calculating things such as this, first time.

Posted

getVehicleTurretPosition has the following example:

local vehicles = getElementsByType ( "vehicle" ) 
-- Loop through the vehicle list 
for vehicleKey, vehicleValue in ipairs(vehicles) do 
    -- Get the vehicle's turret position 
    local x, y = getVehicleTurretPosition ( vehicleValue )  
    -- Convert the positions to degrees, as that's much more useful if you'd want to output it 
    x = math.deg ( x ) 
    y = math.deg ( y ) 
    -- Get the vehicle's name 
    local vehicleName = getVehicleName ( vehicleValue ) 
    -- Tell everyone in the F8 console the turret's position 
    outputConsole ( vehicleName .. "'s turret rotation: " .. x .. ", " .. y .. "." )     
end 

Once the script starts, it'll tell you the rotation of the turret ( the gun on a tank, etc ). However, this will give you errors if the vehicle isn't equipped with a turret.

Posted

If I get it right, returned rotation of turret is relative to vehicle's rotation. So in order to get the target position, you would have to get the aiming vector from turret's rotation, combine it with turret's position using getVehicleComponentPosition and then transform the result into world coordinate system by multiplying it by vehicle's matrix (getElementMatrix).

Posted

By 'aiming vector' I mean the vector pointing to direction where the turret is aiming. And I said which matrix exactly, vehicle's matrix.

  • 2 months later...
Posted

I did myself, using vehicle component position to getPedTargetEnd.

There must be right click and it shows perfect! Thanks everyone whoever helped me.

Special THANKS TO CASTILLO

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...