0
\$\begingroup\$

I am trying to write a movement prediction code. I have found the quadratic method with these topics:

I have implemented this without problems. The problem is how can I add enemy hitbox calculation (I want to fire at edge of enemy for precision)

local cos = targetDirection:dot(toTargetDirection)
local absCos = math.abs(cos)

local sin = math.sqrt(1 - (cos * cos))
local absSin = math.abs(sin)

local cot = cos / sin

local absCot = math.abs(cot)
local delta = 1 - ((cos * cos) + (sin * sin))

local position = targetPosition + targetVelocity * delay
position = position + targetVelocity * network.latency

position = position - toTargetDirection * (target.boundingRadius + width)
position = position - targetDirection * (target.boundingRadius + width)

position = position - toTargetDirection * (absSin * (target.boundingRadius + 
width))
position = position - targetDirection * (absCos * (target.boundingRadius + 
width))

local toPosition = position - sourcePosition
local toPositionDirection = toPosition:norm()
local spellVelocity = toPositionDirection * speed

local a = targetVelocity:dot(targetVelocity) - 
spellVelocity:dot(spellVelocity)
local b = targetVelocity:dot(toPosition) * 2
local c = toTarget:dot(toPosition)

local discriminant = b * b - 4 * a * c

if (discriminant < 0) then
   return
end

local time = 2 * c / (math.sqrt(discriminant) - b)

So far tried this but it's still not casting edge with precision.

\$\endgroup\$
7
  • \$\begingroup\$ Looks like nobody is know the solution :( \$\endgroup\$
    – Dicaste
    Jan 24, 2019 at 19:56
  • \$\begingroup\$ Two possibilities: 1) Nobody knows how to do hitbox calculation (unlikely) 2) Nobody has a clear idea what kind of help you need with hitbox calculation. So, try editing your question to explain in detail what you've tried so far and where you're stuck, or how the results you're getting differ from what you want. Editing to add detail attracts more attention to questions, and makes it easier to write high-quality answers. \$\endgroup\$
    – DMGregory
    Jan 24, 2019 at 20:09
  • \$\begingroup\$ Updated. I want to cast edge because i want to increase hitchance in low range. \$\endgroup\$
    – Dicaste
    Jan 25, 2019 at 15:50
  • \$\begingroup\$ Can you walk us through (or even diagram) an example of how casting an edge gives better hit chance than the alternative you have in mind? \$\endgroup\$
    – DMGregory
    Jan 25, 2019 at 16:24
  • \$\begingroup\$ In mid-short range target can't dodge with backward/inverse movement. It depends on speed. \$\endgroup\$
    – Dicaste
    Jan 25, 2019 at 18:05

0

You must log in to answer this question.