- Joined
- Apr 3, 2012
- Messages
- 31
So I'm using KB3D to create a projectile spell, largely based on some of the examples in the test map. However, it seems there's an issue in the code, where the facing angle is incorrectly calculated - as a result, the projectile dummy unit spawns facing the correct direction, but always faces towards 0 degrees after half a second or so while travelling. This isn't noticeable in the test map, because the spells all use effects like fireballs or boulders where the facing angle doesn't matter, but if you replace one of the dummy units with e.g. an arrow, you can clearly see the issue.
Here's the part of the code that I believe is relevant:
Removing the last part (Make Unit Face Angle) makes the unit always face the angle that it spawned, which could work if you have a fast projectile with low range, as you wouldn't notice the angle change. It's not a "true fix" however.
With some rudimentary testing, I found that decreasing the SetUnitFacing (through division) does nothing, while increasing it (through multiplication) would cause the projectile to actually change facing angle while midair - just, you know, I'm not great at math, so I don't know what the correct formula is, to make the projectile face the right way, instead of spinning to wherever.
Any help would be appreciated.
Here's the part of the code that I believe is relevant:
JASS:
//Calculate the Angle
if ( Target == null ) then
set Angle = LoadReal(udg_KB3D_HA, 5, Loop) + LoadReal(udg_KB3D_HA, 30, Loop)//if there is no unit target
else
set Angle = Atan2(GetUnitY(Target) - Y, GetUnitX(Target) - X)//if there is a unit target
endif
//
if LoadBoolean(udg_KB3D_HA, 16, Loop) then
set Angle = GetUnitFacing(U)*0.0174533
if LoadBoolean(udg_KB3D_HA, 44, Loop) then
if GetUnitCurrentOrder(U) != 851986 and GetUnitCurrentOrder(U) != 851971 then
set b = false
endif
else
set b = false
endif
endif
//Make Unit Face Angle
if LoadBoolean(udg_KB3D_HA, 31, Loop) then
call SetUnitFacing(U, Angle * 3.141592)
endif
Removing the last part (Make Unit Face Angle) makes the unit always face the angle that it spawned, which could work if you have a fast projectile with low range, as you wouldn't notice the angle change. It's not a "true fix" however.
With some rudimentary testing, I found that decreasing the SetUnitFacing (through division) does nothing, while increasing it (through multiplication) would cause the projectile to actually change facing angle while midair - just, you know, I'm not great at math, so I don't know what the correct formula is, to make the projectile face the right way, instead of spinning to wherever.
Any help would be appreciated.