Anubhav Posted December 11, 2014 Posted December 11, 2014 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!
Dealman Posted December 11, 2014 Posted December 11, 2014 I'd assume you should be able to calculate it using getVehicleTurretPosition perhaps?
WASSIm. Posted December 11, 2014 Posted December 11, 2014 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
Anubhav Posted December 11, 2014 Author Posted December 11, 2014 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.
tosfera Posted December 12, 2014 Posted December 12, 2014 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.
Anubhav Posted December 12, 2014 Author Posted December 12, 2014 I know, I tried doing that, din't work for me.
DiSaMe Posted December 12, 2014 Posted December 12, 2014 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).
Anubhav Posted December 13, 2014 Author Posted December 13, 2014 What is the turrent component called? and what do you mean by aiming vector? and which matrix?
Castillo Posted December 13, 2014 Posted December 13, 2014 It was either: "misc_a", "misc_d" or "misc_b".
Anubhav Posted December 13, 2014 Author Posted December 13, 2014 And aiming vector + which vector? how will I know misc_a or misc_b or misc_d?
Dealman Posted December 13, 2014 Posted December 13, 2014 misc_a = Turret (Mesh) misb_b = Gun Mantlet (Mesh) misc_c = Muzzle (Dummy)
DiSaMe Posted December 13, 2014 Posted December 13, 2014 By 'aiming vector' I mean the vector pointing to direction where the turret is aiming. And I said which matrix exactly, vehicle's matrix.
Anubhav Posted February 17, 2015 Author Posted February 17, 2015 Sorry for bumping, but still I don't get this aiming vector. How should I get it?
Anubhav Posted February 17, 2015 Author Posted February 17, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now