- Joined
- Feb 2, 2006
- Messages
- 1,631
I use a periodic timer which has the following function:
It implements a custom camera distance system. The player can increase or decrease the camera distance during the game. Everything works fine except when I disable this timer and reset the camera distance. During video sequences the camera sometimes slowly zooms towards its target.
This code is my enable/disable method:
When disabling the timer I reset the distance back to a certain distance. I suspeact the thistype.cameraTimerInterval value to cause the bug since it means the distance is applied over a small time which is:
I guess I've added the interval to the apply function to prevent any scroll camera functions which could change the distance back?
I am not even sure if this causes the zoom bug.
I have tried to use a new method after disabling the camera timer in every video:
which always waits for the interval and then resets the target distance immediately but it didn't help. The camera still zooms sometimes torwards the target in videos. Btw. when it happens once during the game in a video it will always happen afterwards in every other video.
Sry for the long explanation. Did anybody ever get the same bug of an automatically zooming camera?
JASS:
private static method timerFunctionCamera takes nothing returns nothing
local thistype this = thistype(DmdfHashTable.global().handleInteger(GetExpiredTimer(), 0))
if (not this.isViewEnabled() and not this.view().enableAgain() and AVideo.runningVideo() == 0 and not AGui.playerGui(this.player()).isShown() and AClassSelection.playerClassSelection(this.player()) == 0) then
call SetCameraFieldForPlayer(this.player(), CAMERA_FIELD_TARGET_DISTANCE, this.m_cameraDistance, thistype.cameraTimerInterval)
endif
endmethod
This code is my enable/disable method:
JASS:
/**
* Enables or disables the camera timer which applies the custom camera distance.
* \param enabled If this value is true and the 3rd person view is not enbaled, the camera distance timer is started. Otherwise it is paused.
*/
public method setCameraTimer takes boolean enabled returns nothing
if (enabled and this.isViewEnabled()) then
return
endif
if (enabled and this.m_cameraTimerEnabled) then
debug call this.print("Enabling camera timer twice!")
return
endif
set this.m_cameraTimerEnabled = enabled
if (enabled) then
call TimerStart(this.m_cameraTimer, thistype.cameraTimerInterval, true, function thistype.timerFunctionCamera)
else
call PauseTimer(this.m_cameraTimer)
// TODO wait for thistype.cameraTimerInterval but make sure it is never called from .evaluate!
call SetCameraFieldForPlayer(this.player(), CAMERA_FIELD_TARGET_DISTANCE, this.m_cameraDistance, 0.0)
endif
endmethod
JASS:
public static constant real cameraTimerInterval = 0.01
I am not even sure if this causes the zoom bug.
I have tried to use a new method after disabling the camera timer in every video:
JASS:
/**
* Fixes the camera fields and resets the camera and then applies a camera setup.
* This is necessary since \ref Character and \ref CameraHeight have systems which set camera fields.
* This cannot be done in \ref onInitAction() since it is evaluated and not executed.
*/
public static method fixCamera takes camerasetup cameraSetup returns nothing
// reset z offset for safety, reset immediately, otherwise it might move in video sequences!
call SetCameraField(CAMERA_FIELD_ZOFFSET, 0.0, 0.0)
call TriggerSleepAction(CameraHeight.period) // wait the field time for safety, otherwise the field is set the whole time during videos
// make sure the field is not applied anymore
call TriggerSleepAction(Character.cameraTimerInterval)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, Character.defaultCameraDistance, 0.0)
if (cameraSetup != null) then
call CameraSetupApplyForceDuration(cameraSetup, true, 0.0)
endif
endmethod
which always waits for the interval and then resets the target distance immediately but it didn't help. The camera still zooms sometimes torwards the target in videos. Btw. when it happens once during the game in a video it will always happen afterwards in every other video.
Sry for the long explanation. Did anybody ever get the same bug of an automatically zooming camera?