Making a Player prefab

If you want to control your game's protagonist during gameplay, you need to define a Player prefab. Note that a Player is not strictly necessary - if you are making an interactive storybook, for example, you can do without one.

The basic steps to defining a Player prefab are:

  • Taking a model or sprite and adding the appropriate components to it
  • Tagging the root object as Player
  • Converting the object to a prefab by placing it in your game's Asset folder
  • Assigning the prefab as your player in the Settings Manager

Any Player prefab generally has the following components added:

  • A collider (generally a Capsule Collider for 3D players, and a Circle Collider 2D for 2D players
  • A Rigidbody for 3D players, or a Rigidbody 2D for 2D players
  • The Player script component
  • The Paths script component
  • An Animation or Animator component, depending on your chosen animation engine
  • Audio Source (optional)

If you are working in 3D, place your Player model in the scene and add the components. The Capsule Collider should be adjusted such that it's bottom touches the floor.

Then check all three boxes in the Rigidbody's "Freeze Rotation" field.

At the top of the Player inspector, select the correct Animation engine your Player will use. Here, we are using the Legacy animation system:

In-depth instructions for each animation engine are provided in the Characters section.

Set up the remaining fields as needed. If your Player is a 2D sprite, make sure that the sprite is a child of the empty GameObject that holds your Player script. The 2D Demo player, Brain2D, demonstrates this - you can find it in Assets -> Adventure Creator -> 2D Demo -> Resources.

Then assign this child sprite in the Sprite child field in the Player inspector.

Regardless of your Animation engine, tag the root object as "Player", and put it on the "Ignore Raycast" layer. Turn it into a prefab by placing it in a folder in your Project window. Once the prefab has been made, it can be removed from the scene.

Finally, tell Adventure Creator that this prefab is your Player by dragging the prefab into the "Player" field in the Settings Manager:

Note that you can override your defined Player prefab in a specific scene by placing a new Player object in the scene before the game runs. This also allows you to attach scripts to the prefab that reference scene objects.

More details instructions on creating characters for a chosen animation engine can be found in the Characters tutorial section.

Adventure Creator and this website are copyright Chris Burton, ICEBOX Studios

Go to top
Do NOT follow this link or you will be banned from the site!