3D Survival Game Tutorial | Unity | Part 27 - Our First NPC

Mike's Code25 minutes read

The episode outlines the process for developing a questing system in a game, starting with creating customizable NPCs using Ready Player Me and integrating them into Unity with animations from Mixamo. Key steps include organizing assets in Unity, setting up animator controllers, and implementing interaction and dialog systems to enhance player engagement.

Insights

  • The episode emphasizes the importance of a questing system for player engagement, detailing the process of creating non-player characters (NPCs) using customizable avatars from Ready Player Me, which can be tested but not used commercially, and guiding users through the steps of importing and animating these characters in Unity for an immersive game experience.
  • To enhance player interaction, the episode outlines the creation of a dialog system that includes a user interface for conversation options, alongside a script to manage NPC interactions, ensuring that players can engage meaningfully with the NPCs while preventing movement during dialogues to maintain focus on the questing experience.

Get key ideas from YouTube videos. It’s free

Recent questions

  • What is a questing system in games?

    A questing system in games is a structured framework that provides players with tasks or missions to complete, enhancing engagement and gameplay experience. It typically involves non-player characters (NPCs) who offer quests, guiding players through the game world and narrative. By completing these quests, players can earn rewards, progress in the story, and explore various aspects of the game. A well-designed questing system not only motivates players to continue playing but also enriches the overall gaming experience by integrating challenges and objectives that align with the game's themes and mechanics.

  • How do I create a non-player character?

    To create a non-player character (NPC), you can start by using a customizable avatar model from platforms like Ready Player Me. This allows you to design an NPC that fits your game's aesthetic. After customizing your avatar, you will need to download it as a GLB file and then convert it to an FBX file using Blender, a free 3D modeling software. This process involves importing the GLB file into Blender, exporting it as FBX, and ensuring that all textures are properly unpacked. Once you have your FBX model, you can organize it within your game development environment, such as Unity, to prepare it for animation and interaction.

  • What is Mixamo used for?

    Mixamo is an online platform that provides a library of animations and tools for character rigging, primarily used in game development. It allows developers to upload their 3D character models and automatically rig them for animation. Once rigged, users can select from a variety of animations, such as walking, talking, or idle movements, and download these animations in formats compatible with game engines like Unity. This streamlines the animation process, enabling developers to bring their characters to life quickly and efficiently, enhancing the overall gameplay experience with dynamic character movements.

  • How do I set up animations in Unity?

    To set up animations in Unity, you first need to import your character model and the animations you downloaded from Mixamo. After importing, create a new folder for your NPC textures and extract the materials from the model to apply the correct textures. You will then create an animator controller, which links your NPC to the animations. In the animator window, you can drag your animations into the workspace, setting one as the default state, typically the idle animation. By enabling loop time for the idle animation, you ensure it plays continuously, providing a natural appearance in the game environment. This setup is crucial for achieving smooth and realistic character movements during gameplay.

  • What is a dialog system in games?

    A dialog system in games is a feature that allows players to engage in conversations with NPCs, often presenting choices that can influence the game's narrative or outcomes. This system typically includes a user interface (UI) with text, buttons, and options for players to select during interactions. It is designed to enhance storytelling by providing players with the ability to make decisions that affect their experience. Implementing a dialog system also involves managing player movement, ensuring that players cannot move away while engaging in conversations, which helps maintain immersion and focus on the narrative elements of the game.

Related videos

Summary

00:00

Creating Engaging NPCs for Game Development

  • The episode focuses on developing a questing system, essential for player engagement, starting with creating NPCs to provide quests, which will be covered over several episodes.
  • To create an NPC, you can use a model from Ready Player Me, which allows customization but cannot be used commercially; it's suitable for testing purposes.
  • After customizing your avatar on Ready Player Me, download it as a GLB file, then convert it to an FBX file using Blender, a free 3D modeling software.
  • In Blender, import the GLB file, then export it as an FBX file; ensure to unpack resources to retrieve textures, which are stored in Blender's main folder.
  • Create a new folder structure in Unity: Models > NPC > First NPC, and import the FBX model and textures into the appropriate folders for organization.
  • Use Mixamo to create animations for your NPC; upload your rigged character, which Mixamo will prepare for animation, and download it as an FBX for Unity.
  • Download two animations from Mixamo: an idle animation and a talking animation, ensuring to select "download without skin" and use FBX for Unity format.
  • In Unity, import the base model and animations, then create a new folder for NPC textures, extracting materials from the model to apply the correct textures.
  • Adjust the materials in Unity by dragging the appropriate textures onto the model's materials, ensuring to set smoothness to zero for a non-reflective appearance.
  • Finally, position the NPC in the game environment, scale it to match player size, and apply the animations to ensure natural movement, completing the NPC setup.

16:18

Creating Interactive NPCs in Game Development

  • Select the desired animations using Ctrl D, then delete unnecessary animations, retaining only the required ones for the NPC model.
  • Create an animator controller by right-clicking, naming it "First NPC Controller," and dragging the NPC into the controller slot to link them.
  • Open the animator window via Window > Animation > Animator, then drag both animations into the window, setting the idle animation as the default state.
  • Enable loop time for the idle animation to ensure it continuously plays, confirming the model's movement in the game scene.
  • Add a box collider to the NPC, adjusting its position to prevent players from passing through, and create a trigger area for player interaction.
  • Develop a generic NPC script to manage interactions, including a public boolean to track player proximity and a trigger collider for interaction detection.
  • Modify the selection manager to handle NPC interactions, displaying a "talk" text when the player hovers over the NPC and left-clicks.
  • Create a dialog system with a canvas, buttons, and text mesh pro for conversation options, ensuring the UI can be opened and closed based on player interaction.
  • Implement functionality to disable player movement while the dialog UI is open, ensuring the player cannot move away during conversations or quest interactions.
Channel avatarChannel avatarChannel avatarChannel avatarChannel avatar

Try it yourself — It’s free.