ShadowSnipe4
New Member
- Reaction score
- 4
okay, I made a set of triggers for my first person camera views, and they work fine in single player. So I was all happy thinking I had finally gotten it to work.
But then I tried to play it on bnet with a friend earlier today and to my horror, the cameras messed up and only looked at the wrong direction etc. I tried it in single player again and it worked fine. I've spent a long time working on this stupid trigger and it seems like I'll never get it right. Hopefully someone can give me some insight as to why the crappy thing wont work. :banghead:
Heres the code.
And
But then I tried to play it on bnet with a friend earlier today and to my horror, the cameras messed up and only looked at the wrong direction etc. I tried it in single player again and it worked fine. I've spent a long time working on this stupid trigger and it seems like I'll never get it right. Hopefully someone can give me some insight as to why the crappy thing wont work. :banghead:
Heres the code.
Code:
function Trig_First_Person_View_Target_Actions takes nothing returns nothing
local integer currentPlayer = 0
local unit currentUnit = null
local location currentPosition = null
local location positionToMoveTo = null
local unit cameraUnit = null
loop
set currentUnit = udg_MoveUnit[currentPlayer + 1]
set cameraUnit = udg_CameraUnit[currentPlayer + 1]
if currentUnit != null then
set currentPosition = GetUnitLoc(currentUnit)
set positionToMoveTo = PolarProjectionBJ(currentPosition, 64, GetUnitFacing(currentUnit))
call SetUnitPositionLocFacingBJ(udg_CameraUnit[currentPlayer + 1], positionToMoveTo, GetUnitFacing(currentUnit))
call RemoveLocation(currentPosition)
set currentPosition = null
call RemoveLocation(positionToMoveTo)
endif
set positionToMoveTo = null
set currentPlayer = currentPlayer + 1
exitwhen currentPlayer > 9
endloop
set currentUnit = null
set cameraUnit = null
endfunction
//====================================================================== =====
function InitTrig_First_Person_View_Target takes nothing returns nothing
set gg_trg_First_Person_View_Target = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_First_Person_View_Target, 0.05 )
call TriggerAddAction( gg_trg_First_Person_View_Target, function Trig_First_Person_View_Target_Actions )
endfunction
And
Code:
function Trig_First_Person_View_Actions takes nothing returns nothing
local integer currentPlayer = 0
local unit cameraUnit = null
local location currentPosition = null
loop
set cameraUnit = udg_CameraUnit[currentPlayer + 1]
set currentPosition = GetUnitLoc(cameraUnit)
if cameraUnit != null then
call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(cameraUnit), 0.05)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 100, 0.05)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 3, 0.05)
call SetCameraField(CAMERA_FIELD_ZOFFSET, 83, 0.05)
call PanCameraToTimedLocForPlayer(Player (currentPlayer + 1), currentPosition, .05)
call SetCameraTargetControllerNoZForPlayer( Player (currentPlayer), udg_CameraUnit[currentPlayer + 1], 0, 0, false )
endif
set cameraUnit = null
call RemoveLocation(currentPosition)
set currentPosition = null
set currentPlayer = currentPlayer + 1
exitwhen currentPlayer > 9
endloop
endfunction
//====================================================================== =====
function InitTrig_First_Person_View takes nothing returns nothing
set gg_trg_First_Person_View = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_First_Person_View, 0.05 )
call TriggerAddAction( gg_trg_First_Person_View, function Trig_First_Person_View_Actions )
endfunction