Day 61 — Setting up the Scene for Player Movement
Hey and welcome!
With the look into cutscenes finished it’s time to make a game out of our project starting with implementing a way for our player to navigate around the environment. To do that we’re going to use a point and click system this time instead of the usual key press movements. First though we need to set up our scene so that it’s ready to handle the movement so let’s get started!
To start things off we’re going to need to bake our scene in order to create a navigational mesh so that Darren is constrained to the environment and won’t walk through walls or objects, this is a pretty important step for 3D development since it’s not really efficient to hard code a set value that Darren can’t go beyond like we did for our space shooter.
To get started, click on the floor in order to open it in the hierarchy and the click on the FloorCollider object here. Next click Window > Ai > Navigation to bring up the nav mesh window and then click on the bake tab and choose the Bake option.
You’ll notice that the floor has turned blue signalling that a nav mesh has been successfully baked, everywhere within this blue area is where Darren and the guards are able to move about in. Now the reason that the baking tool knew exactly where to bake is because of the premade collider mesh in the FloorCollider object that was used to map out the floor since the floor in reality is all just one object.
Now let’s make a placeholder object for our player that we can use to test out the movement. In the hierarchy create a 3D capsule object and place it where Darren lands from his rope. Then add a new component called the Nav Mesh Agent, this component let’s our capsule object know that there’s a nav mesh to interact with and it will confine the player to it.
Also if you click into the Camera_Progression_Angles object in the hierarchy you’ll see six camera objects in there that just have positional values, we’ll be using those values and assigning them to the main camera when Darren hits certain triggers in order to change where the camera is looking for the game view. To start with just drag and drop you Main Camera object into here and copy and paste the transform component values from the Camera_One object into the main camera to get a view like this:
If you need to adjust the view at all make sure you change the values in the Camera_One object as well. That’s all for the set up here, next time we get back to coding finally and implement point and click movement in our game!