Monday, February 27, 2017

Day 16: Player Movement

First, I need a player. I'm just going to use a simple cube; nothing too fancy. I called it "Player_Model", and made it a blueish colour.


Now for the fun stuff: scripting the world interaction. The WorldInteraction script will allow the game to detect what is being clicked and react accordingly.

I started with a script that detects whether or not the mouse button is clicked, and if what it's clicking has a specific tag.

I then went back to my scene, and selected everything in the "environment" tab and made all of it "static". This means that the game expects them to not move, and won't  have to recalculate it every frame.

I then selected everything that I didn't want the player to be able to walk on, like the trees, rocks, barrels and mountains, and set them to "not walkable".
Next, I "baked" the scene to apply the walkable area to the scene. Everything in blue can be walked on by the player.

I then added, to the player, a "NavMeshAgent". This defines the collision dimensions, speed, acceleration, and how far the object stops from its destination.

Here's the script I added.

Unfortunately, there's an issue with the "NavMeshAgent" lines for some reason. Next class, I will try to fix that.


No comments:

Post a Comment