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