Jump to content

CreateProjectile


XaskeL

Recommended Posts

Posted

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

Posted

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

  • Moderators
Posted

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.

 

 

Posted
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

  • Moderators
Posted
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!

 

 

  • Like 2
Posted
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!

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