Jump to content

Calculate Vector from 2 positions


Einheit-101

Recommended Posts

Hello community.

I have a question related to Vector calculation. I got 2 Objects with their X Y Z coordinates and i want to calculate a velX, velY and velZ from object 1 to object 2.

I am still searching on the internet for a solution but i cant find what i want. Could anyone please help me with this problem?

Mfg Einheit-101

Link to comment

Take away one object's X, Y and Z from another object's X, Y and Z.

local x,y,z = getElementPosition( obj1 ); 
local x1,y1,z1 = getElementPosition( obj2 ); 
local yourVector = { x-x1, y-y1, z-z1 }; 

I hope that's what you want.

Link to comment

Yes, my friend, thank you! This exactly does what i was searching for! Unfortunately “getVehicleComponentPosition“ does not return useful xyz values for the misc_c component, so i have to wait with my script until there is something like “x,y,z = getVehicleMuzzlePosition(theVehicle)“. I wanted to create a custom Rhino cannon, but it seems that CLEO is more advanced with vehicle scripting functions than MTA...

Link to comment

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