ForceUpdateDependencies
Last updated
Was this helpful?
Last updated
Was this helpful?
The ForceUpdateDependencies for the Camera performs all of the same functionality as the call, but it also does a few extra things. Specifically, it updates the mins and maxes of the camera, and recalculates its View and Project matrices. For information on ForceUpdateDependencies as it relates to in general, see the page.
If you are writing a game where you need to perform logic based off of the Camera's position or edge values, then you need to call ForceUpdateDependencies prior to asking the Camera for any of these values if the Camera is attached to another object. Games often need to know a Camera's position in custom code. Consider the following examples:
You may be developing a top-down game which shows arrows on the edge of the screen to indicate where off-screen enemy units are located. The positioning of these units requires math using the Camera's position.
The calculation of the visible in a requires up-to-date Camera position values.
Your game may be a 3D game which uses a 2D for HUD. The 2D elements in your game may be based off of the 3D position of elements in the world (this is a more complex case).
If your Camera is attached to another object, you will need to call ForceUpdateDependencies to make sure that all values are up-to-date.
The order of calls matters in your game. The following code gives an example of how you would want to structure your Screen's CustomActivity if you plan on using the Camera's positioning:
As mentioned above, if you are translating between 3D and 2D coordiantes, you may still need to call ForceUpdateDepencies even if you are only updating the Camera's position manually. The reason for this is because you may end up using the Camera's matrices for calcualting the translations, and these are only updated when the Camera's dependencies are updated. Therefore, if you are experiencing unexpected behavior when translating between 3D and 2D (or 2D and 3D), then you should try calling ForceUpdateDependencies.