Camera Confiner Layer Mask

00:00:00:07 - 00:00:26:17

Peter

We have prepared our layer of masks. Those were the obstacles and the agent. But there is one more collider that we haven't included. Now, if we select our player agent in a hierarchy and select the collision detector, and if we go to the contact fielder, we can check use triggers. Now, often our recasting will detect everything if we don't define it in the contact filter that it shouldn't.


00:00:26:28 - 00:00:48:19

Peter

So if we have this checked, we are going to be detecting all the types of colliders, so the colliders and the triggers. If I also said the layer mask to detect default. So we haven't really specified anything in our collision detection for our recast. If I now press play, we will see that we cannot move. And why is that?


00:00:49:05 - 00:01:14:07

Peter

Well, if we take a look at the hierarchy in the system, so we have this camera confinement, this is a polygon collider that is a trigger. But this on the whole map, on the whole area of our map, because it is confining the camera. So if we haven't specified in our recasting logic that it should not detected the triggers or the default layer, we would be in trouble and we would have a strange bug.


00:01:14:09 - 00:01:47:19

Peter

So let's stop it and let's place our holy gold collider on its separate layer so that we can avoid any sort of bugs that are connected with the collider that is spaced on the whole map. And this would happen with our camera confined. So before that, maybe let's go back to our collision detector of the agent and let's said use trigger or maybe actually some of the player agent object overrides and let's revert all so that the collision detector will be reset to use the same setup as the prefab.


00:01:48:04 - 00:02:15:00

Peter

Now let's go back to the camera Consignor. And we want to select the layer and we want to select our layer at the bottom and in the layers list, we are going to add a camera confined. There may maybe and this will be a new layer that we have in our setup. We're going to go back to the hierarchy to do the camera confinement, and we are going to set its layer to be the camera consignor.


00:02:15:15 - 00:02:34:08

Peter

Now, we have no need right now to do this, but later on it is very easy to forget about it. And then when you buy the folded, the detector, all the objects on the default layer would have a collision with the Polygon Collider. Even if it is at trigger, we would often detect it and wonder why our detection is not working properly.


00:02:34:20 - 00:03:02:05

Peter

So let's press play now. We should see that the camera confinement is still working. It is still stopping at the edge, but at the same time we can still collide with other objects, but not with the camera confined. That is a space across that whole area of our farm map and probably will be placed on top of other levels in our game to confine the camera to only be able to move to show us what is prepared for the there to be seen.


00:03:02:12 - 00:03:16:06

Peter

Okay, let's stop our project now. We could create a prefab out of our camera confined, but we are going to probably do that when we create a new scene for our game. For now, let's make sure to save our scene.



Complete and Continue