Jump to content

CreateProjectile


XaskeL

Recommended Posts

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
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
Link to comment
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

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