Category: Unity

  • Firing a Projectile (with Physics)

    Firing a Projectile (with Physics)

    This lesson covers how to spawn a projectile when the user presses the default fire button (left mouse click) using the Input System. You should know how to / already have: First Person player controller Input Actions with a Fire action binding already setup. A level to test the scripts and code on. You can…

  • Laser Tower that automatically attacks targets within range using (draw line in game)

    Laser Tower that automatically attacks targets within range using (draw line in game)

    This guide will demonstrate how to make a tower that will shoot a simulated laser at a specified time to the first object that moves within it’s range. You need to be able to: move a character around on the scene Have a Player Properties script attached to the player with a public health variable…

  • Adding a Canvas and UI to a scene

    Adding a Canvas and UI to a scene

    You can have multiple Canvas’ on a scene. Open a scene. Go to GameObject > UI > Canvas This adds the Canvas and the EventSystem objects Select EventSystem In the Standalone Input Module component click the button Replace with InputSystemUIInputModule. This enables the UI to work with the Input System Often you want the Canvas…

  • Environmental Damage: Taking Damage from an Area

    Environmental Damage: Taking Damage from an Area

    This guide shows how to create an environmental obstacle. In this case a section of the map set to be lava that will inflict damage over time while the player stays in the area. The code has been written so that it can be dropped onto enemy or other objects and have the same effect…

  • Enemy AI: Infinite Spawn Point / Tower

    Enemy AI: Infinite Spawn Point / Tower

    This lesson assumes that you have completed the guide on how to get an enemy object to chase the player using the nav mesh agent. You can find the lesson here. There is an example of an infinite enemy spawn tower which can be downloaded here. This will set an object that will infinitely spawn…

  • Enemy AI: Chase a player

    Enemy AI: Chase a player

    This example will have an enemy player chase a player object. An example of an enemy chasing a player (with a spawn point created) can be found here. It assumes that you already have a player prefab and an enemy prefab created. Setup your level / environment with the enemy object (with no scripts) Add…

  • UI Buttons to Spawn and Despawn Objects (Grid Layout)

    UI Buttons to Spawn and Despawn Objects (Grid Layout)

    Download the example here. This example builds on from the spawn and despawn prefabs in the scene tutorial. This tutorial will add a set of UI buttons that will allow you to select a prefab to spawn. The grid layout component is used to align the buttons. Create the prefabs you want to use for…

  • Spawn and Despawn Objects when you Mouse Click in a Scene

    Spawn and Despawn Objects when you Mouse Click in a Scene

    There is an example of this here. Setup a scene with varied terrain on it. Create prefabs that can be used to spawn objects. You only need one for this example. Set the parent of the prefab to have a tag named Player (or whatever you wish). We will use this later to check if…

  • Custom Cursors for a Pan and Scroll Camera using Cinemachine

    Custom Cursors for a Pan and Scroll Camera using Cinemachine

    You can access a windows example here. You need to have completed the lesson on creating a Pan and Zoom camera before attempting this one and expecting it to work fully. You can use this to learn how to change cursors though. The code below is what is used to change the cursor. It takes…

  • RTS Style Pan and Zoom Camera using Cinemachine

    RTS Style Pan and Zoom Camera using Cinemachine

    This lesson will have you create a camera that can pan and zoom using a Cinemachine Virtual Camera and the Input System. This is similar to RTS Style Cameras in Command and Conquer, Star Craft, and League of Legends. You can download an example build of this here. Create a scene and add the terrain…