Tuesday, March 7, 2017

Day 21

Today I continued the tutorial.

I worked a bit more on the camera and then I moved on to the enemy.

I worked on a simple code on the camera that made it follow the player wherever it went.
What this code does pretty much is it gets the distance between the player and camera and then makes the camera equal the players position + the offset so that it'll always be above the player. It then uses Vector.Lerp to add a sort of smoothing to the camera so that it's not so rough.

And now the camera follows the player. 

Now next up I needed to make the first enemy called Zombunny. The model and everything was already set up in the prefabs but I had to still set up the animation and the navmeshagent. So I set up the animation in a similar way to the player and made its default state the running mode. then I made a transition from running to idle to activate when the player dies. 
Now I had to work with the navmeshagent now. I added a new component to the zombunny called a navmeshagent. What a nav mesh agent does is it bakes a mesh based on your settings and allows the object to move on that area. It automatically finds the fastest route to the destination and it is called every frame. Now I had to make a little script that makes the zombunny always follow the player.

The script was already written but I could've wrote it myself.
Now the zombunny follows me.

Tomorrow I will continue the tutorial.

No comments:

Post a Comment