I have been struggling to get unit to update cast position in 'real time' before OnSpellStart().
The thing is, spell remembers only position of the cursor when spell is being called, and I can still access it in OnAbilityPhaseStart. Yet it is immutable and just stays what it is from the beginning.
The GetCursorPosition inside OnSpellStart always returns Vector[0,0,0] so does the OnCahnnelThink and OnProectileThink
The walkaround I'm trying to use is sending custom event from panorama directly to the spell to update cursor position and it looks like this:
||`juggernaut_ability3 = class({})
LinkLuaModifier( "modifier_juggernaut_ability3", LUA_MODIFIER_MOTION_NONE )
local Cursor;
local pId
local caster;
local origin
local listen = false
function juggernaut_ability3:Spawn()
if IsServer() then
pId = self:GetCaster():GetPlayerID()
CustomGameEventManager:RegisterListener( "updateCursor",Dynamic_Wrap(juggernaut_ability3, "updateCursor"))
self:SetLevel(1)
caster = self:GetCaster()
origin = self:GetCaster():GetOrigin()
end
end
function juggernaut_ability3:updateCursor(event)
if listen == true then
if event.PlayerID == pId then
Cursor = Vector(event.positionX,event.positionY,event.positionZ)
local cur = Cursor-origin
caster:SetForwardVector(cur)
end
end
end
function juggernaut_ability3:OnAbilityPhaseStart()
caster = self:GetCaster()
origin = self:GetCaster():GetOrigin()
listen = true
return true
end
function juggernaut_ability3:OnSpellStart()
if IsServer() then
listen = false
`||
**My problem is: if there are multiple juggernauts on the server, then only 1 player can set the cursor, while cursor of the others is tied to that spot. **