Jump to content

Vehicle aim


Anubhav

Recommended Posts

  
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.

Link to comment

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.

Link to comment

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).

Link to comment
  • 2 months later...

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...