Skill Tree Activated

The quest to become an indie game developer

C#CodingTrainingUnity

2D Game Dev – Character Controller & Keyboard Input

Day 057 #100DaysOfCode

I made big advances in working with Unity C# scripts today.

By starting the Ruby’s Adventure: 2D Beginner course via Unity Learn I was walked through how to set up a character controller script and incorporate basic keyboard controls.

The tutorial went step-by-step and carefully explained what every line of code was for and did. Absolutely amazing! I wrote my notes directly in the code so I could remember everything I was learning:

1st Iteration: Writing the basic structure to get a character sprite to move across the screen on its own. This taught Vector types and using the Transform component of a GameObject.
2nd Iteration: Added keyboard input for horizontal control and learned about using Debug.Log to send info to the Unity console while your game is running.
3rd Iteration: Condensed the code and added keyboard controls for vertical movement. Also learned how to use Time.deltaTime to regulate movement and framerate based on the amount of time it takes Unity to render those frames. This normalizes movement speed on different machines where hardware renders at different rates.

Leave a Reply

Your email address will not be published. Required fields are marked *