Implementing movement
Almost every object in a game moves one way or another: the player character with the keyboard, enemies through AI, bullets that simply move forward, and so on. There are several ways of moving objects in Unity, so we will start with the simplest one— that is, using the Transform
component.
In this section, we will examine the following movement concepts:
- Moving objects through
Transform
- Using input
- Understanding Delta Time
First, we will explore how to access the Transform
component in our script to drive player movement, later applying movement based on the player’s keyboard input. Finally, we will explore the concept of deltatime to make sure that movement speeds are consistent on every computer. We will start learning about the Transform
API to make a simple movement script.
Moving objects through Transform
Transform
is the component that holds the translation, rotation, and scale of an object, so...