XaskeL Posted June 19, 2018 Share Posted June 19, 2018 Please, help me, as run rocket to x,y,z coords from earth-vehicle? .. Var arguments take function: startx, starty, startz, rotx, roty, rotz, velx, vely, vely Link to comment
XaskeL Posted June 19, 2018 Author Share Posted June 19, 2018 I need to calculate the velocity of the projectile, along the axes, so that it flies where I need it. Manually defined; start point: pos vehicle, the end point is indicated by the player on the map Link to comment
Moderators IIYAMA Posted June 19, 2018 Moderators Share Posted June 19, 2018 The easiest way would be creating an object on the map(server-side strongly recommended because of the synchronization). And let a heat seeking rocket fly to it. Link to comment
XaskeL Posted June 19, 2018 Author Share Posted June 19, 2018 2 hours ago, IIYAMA said: The easiest way would be creating an object on the map(server-side strongly recommended because of the synchronization). And let a heat seeking rocket fly to it. I wanted to do it. I'll try later but still, I'm waiting for a mathematical way Link to comment
Moderators IIYAMA Posted June 19, 2018 Moderators Share Posted June 19, 2018 local findRotation = function ( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end local findPitch = function (camerax,cameray,cameraz,pointx,pointy,pointz) local dX=camerax-pointx local dY=cameraz-pointz local dZ=cameray-pointy local pitch=math.atan2(dY,math.sqrt(math.pow(dZ,2) + math.pow(dX,2))); return pitch end local targetX, targetY, targetZ = 0, 0, 0 local elementX, elementY, elementZ = getElementPosition(projectile) local rotZ = findRotation(targetX, targetY, elementX, elementY) + 180 local pitch = findPitch(targetX, targetY, targetZ, elementX, elementY, elementZ) local rotX = pitch*(180/math.pi) These are the global math functions you need, which I ripped out of my own script. You probably need some adjustments to them in order to make it work for your script. The variable names do speak for them self, so good luck with it! 2 Link to comment
XaskeL Posted June 19, 2018 Author Share Posted June 19, 2018 52 minutes ago, IIYAMA said: local findRotation = function ( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end local findPitch = function (camerax,cameray,cameraz,pointx,pointy,pointz) local dX=camerax-pointx local dY=cameraz-pointz local dZ=cameray-pointy local pitch=math.atan2(dY,math.sqrt(math.pow(dZ,2) + math.pow(dX,2))); return pitch end local targetX, targetY, targetZ = 0, 0, 0 local elementX, elementY, elementZ = getElementPosition(projectile) local rotZ = findRotation(targetX, targetY, elementX, elementY) + 180 local pitch = findPitch(targetX, targetY, targetZ, elementX, elementY, elementZ) local rotX = pitch*(180/math.pi) These are the global math functions you need, which I ripped out of my own script. You probably need some adjustments to them in order to make it work for your script. The variable names do speak for them self, so good luck with it! Thank you very much! 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