Unity Character Controller Including Enemy

Day eight of the project looking into the Unity Character Controller and enemy movements. We continue with the Unity3d course by Joshua Kinney (Link). If you are following along and don’t have a subscription to PluralSight, then go to our home page. On the home page, you will find out how to get setup with a FREE PluralSight account for 6-months.

unity character controller

 

Unity Character Controller

Might need to copy the robot file from the lessons zip file, that is if you are following along. The Unity Character Controller animations have already been done for us. The scope of this course does not include creating the animations.

Run, Walk, and Idle

We are going to setup player and the player animations one at a time. As mentioned in the previous paragraph, all the animations are already done for us. We now have to setup the player model settings, as well as the rig and animations settings. After all the setting is verified, we can move onto the animator tab. The animator tab is where we coordinate the different animations, such as idle state, running and walking.

Create The Transitions

Transitions are the blending of one animation into another. We will add the transition from idle to running and back from the run animation to idle. As per the course, we will not be doing the walk animation at this time. A boolean switch will be added to both the run and idle transitions as we will be adding some scripting in the next lesson.

Scripting for the Character

The C# programming that I covered in the previous days of my project is now useful. If you want to read the posts about the scripting lessons, then click on the following links:

http://gametoolkits.com/learn-c-sharp-programming-with-c-sharp-fundamentals.html
http://gametoolkits.com/assembly-in-c-sharp-programming.html
http://gametoolkits.com/members-and-control-flow-in-c-sharp.html
http://gametoolkits.com/object-oriented-programming-concepts-in-c-sharp.html

When you are following along in the lessons, Joshua might mention MonoDevelop. If your scripting editor opens as MonoDevelop, then you are using the same editor as Joshua. However, if the editor opens Visual Studio, that is ok as its what I am using. The scripting will use both C# code as well as Unity3d functions.

We will investigate the camera rig settings. It will unfortunately not be scripted by us as this falls outside the scope of these lessons. We do look at the camera setup and the camera rig setup.

The Game Enemy

In this section remember to import not on the EnemyMovement script, but also the MotherShip and PlayerInventory scripts. You will get errors If you do not introduce all three. Once again the scripting is beyond the scope of these lessons. Finding scripts is one of the nice things about the Unity community as there are lots of free scripts available. Having free scripts allows you to import, drag and drop the code as needed.

The nav mesh is also going to be setup in these lessons. The nav mesh determines where the enemy can navigate.

At this stage of the game development we need to add the game pickups.  The pickups, for the game itself, are used to disable the enemy mother ship.  If the player gets enough pickups and reaches the mother ship, the player wins.  If one of the enemy catches the player, then the player loses.

Conclusion

Creating the Unity Character Controller and enemy movements was a fun exercise. The unity character movement script is something that I will be using once I start to develop my game.

I have completed day 8 of my training on day 9, oops! I will now have to catch up a day.

NOTE: There are some bugs in the game so far. I am not that concerned with the bugs as I am still in the stage of learning Unity3d.

Shares