This version still uses the static distance implementation for finding the dead zone region, which simply measures the distance from the center of the screen. With this implementation, the character begins pushing the screen too early when moving further into space. Conversely, the character risks falling off the screen when moving too close to it.

2024-12-18_06-17-39.mp4

In this version, we will constantly update the bonds as the character moves closer and further away from the camera. Additionally we will add dead zone the y-axis.

Setting up Variables

Let's set up a few variables to simplify scene configuration.

For example, if you set BoundsXOffset to 100, the camera will start moving when the character is 100 units from either the left or right edge.

For the Y-axis, we need separate far and near bounds, unlike X and Z axes.

<aside> 📌

Note that you can also use separate variables for left and right edge bounds if needed.

</aside>

Find the Key Points

To dynamically update the bounds, we need to calculate the distance from the screen's center to its edge. This allows us to update BoundsX and BoundsY.

Since the center-to-edge distance varies with character position, we must calculate based on the character's current distance.

image.png

Input

When XEdgeOffset and YEdgeOffset are both 0.5, the intersection occurs at the screen's center.