substance
New Member
- Reaction score
- 34
I have unit that has a gun (based off the marine model) and i'm using lightning to create an effect where it looks like the lightning is coming from the caster's gun to the target unit. Obviously by default the lightning starts from origin of the caster.
I figuired i could use projection to find the point in front of the caster but that looks good in some angles but it others it all out of wack, currently im trying :
(oh btw this is a little backwards because the lighting STARTS at the target unit and ends at the caster)
Yes, I know its supposed to be 'x + distance' and I have 'x - distance' but again, it's backwards starting from the target unit and ending at the caster, so basically the lightning has to fall short a bit before reaching the caster so it looks like its ending infront of him instead of instead of him.
Any ideas, or is lightning just whacked.
I figuired i could use projection to find the point in front of the caster but that looks good in some angles but it others it all out of wack, currently im trying :
(oh btw this is a little backwards because the lighting STARTS at the target unit and ends at the caster)
JASS:
local real casterX = GetUnitX(data.SoP_caster)
local real casterY = GetUnitY(data.SoP_caster)
local real targetX = GetUnitX(data.SoP_target)
local real targetY = GetUnitY(data.SoP_target)
local real angle = bj_RADTODEG * Atan2(targetY - casterY, targetX - casterX)
local real lightningendX = casterX - 80 * Cos(angle * bj_DEGTORAD)
local real lightningendY = casterY - 80 * Cos(angle * bj_DEGTORAD)
call MoveLightning(data.SoP_lightning, true, targetX,targetY,lightningendX,lightningendY)
Yes, I know its supposed to be 'x + distance' and I have 'x - distance' but again, it's backwards starting from the target unit and ending at the caster, so basically the lightning has to fall short a bit before reaching the caster so it looks like its ending infront of him instead of instead of him.
Any ideas, or is lightning just whacked.