Explore Free Action Game Tutorials – GameDev Academy https://gamedevacademy.org Tutorials on Game Development, Unity, Phaser and HTML5 Thu, 06 Apr 2023 10:05:05 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 https://gamedevacademy.org/wp-content/uploads/2015/09/cropped-GDA_logofinal_2015-h70-32x32.png Explore Free Action Game Tutorials – GameDev Academy https://gamedevacademy.org 32 32 A Guide to Adding Bullets for FPS Godot Games https://gamedevacademy.org/godot-bullet-fps-tutorial/ Thu, 06 Apr 2023 09:59:03 +0000 https://gamedevacademy.org/?p=19756 Read more]]> The first-person shooter (FPS) genre of video games is one of the most popular among players – with huge franchises like Call of Duty, HaloApex Legends, and many others.

While FPS games have a lot of different features that could be covered, there is one mechanic that stands above the rest: shooting. Even in a versatile environment with tons of different gun types, implementing the shooting of the bullets looks pretty much the same.

With that in mind, we’ve prepared this Godot tutorial where we’re going over the entire process of creating the bullet object and setting up its properties in the game engine. We’ll also cover the scripting of the projection of the bullets out of the gun being used in the game.

If you’re ready, let’s get started!

Project Files

You can download a copy of the source code files (including the assets) for the project done in this tutorial here.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Creating The Bullet

We’re going to start by scripting the ability for our player to shoot. For that, let’s create a new scene and save it as “Bullet.tscn”:

Creating a new scene in Godot

Here, we’re going to create the bullet prefab that we’ll be spawning at the muzzle. Create a new root node of type Area, by clicking on ‘Other Node‘ and searching for “Area”:

Creating the bullet prefab by adding an Area root node in Godot

Area is a physics node that won’t actually collide with other objects, but it can detect collisions as something goes through its collider. This is useful for bullets as they don’t need to bounce off or collide with anything, we just need it to detect when it has entered another object:

Renaming our Area node to "Bullet" in Godot

Rename this node to “Bullet”, and drag the bullet model (Models > Weapon > ammo_pistol.obj) into the scene as a child node of Bullet:

Dragging the bullet model as a child of our Bullet node in Godot

Note that the “ammo_pistol.obj” asset we’re using here can be found in the project files link above.

In the inspector, set the Transform > Translation to (0, 0, 0) to center it in the scene and set the Scale to (10, 10, 10). Lastly, set the rotation to (90, 0, 0) so it is facing forward, not upward:

Setting up the bullet model in Godot

We’ll now add another child node (CTRL+A) of type CollisionShape to the root node Bullet:

Adding a CollisionShape node to our Bullet in Godot

Set the collider shape to ‘Capsule‘ in the Inspector. Then, click on the text “Capsule” to view more options and set the radius to 0.03 and the height to 0.06:

Setting up the collider's shape, radius, and height in Godot

Adding a Timer

We need to add just one more component (CTRL+A), which is a Timer, again as a child node of Bullet:

Adding a Timer as child node of Bullet in Godot

Timer is a node that waits for a given time (1 sec by default) and then emits a signal. A signal in Godot refers to an event that a node can call out once it meets a certain condition.

In the inspector, you can choose the Node tab and see the list of signals available:

Available signals for the Timer node in Godot

Back to the Inspector panel, let’s set the wait time to 5 and enable ‘Autostart’.  This will allow the timer to automatically start as soon as the game starts:

Setting up the Timer in Godot

Next, select the root node (Bullet) and create a new script by going to Script > [empty] > New Script:

Creating a new script in Godot

First of all, we are going to create variables for the speed and damage of our bullet as follows:

extends Area

var speed : float = 30.0
var damage : int = 1

To move the bullet forward, we can multiply the global transform on the z-axis (global_transform.basis.z) by speed and apply it directly on translation within func_process(). Note that delta is multiplied here to convert it from 30 units per frame to 30 units per second:

extends Area

var speed : float = 30.0
var damage : int = 1

func _process(delta):
  
  translation += global_transform.basis.z * speed * delta

Now we need to create another function that destroys the bullet whenever the bullet either runs out of the timer or hits an object. For this, we can use queue_free() which destroys the node:

func destroy ():
  
  queue_free()

Save the script. Go back to the Timer node, open up the Node panel, and double-click on the timeout() signal. It will ask us to connect a signal to a method.

In the Receiver Method input field, type in the name of the function to call (i.e. “destroy”) and hit ‘Connect’:

Connecting the Timer node to the destroy function

Our script now has this little green mark on the left which signifies that this function is connected to a signal. This function will be called once a signal is emitted:

The destroy function is now connected to a signal

Detecting An Enemy

Following, we need to be able to detect when the bullet enters another collider. Select the root node (Bullet) and open up the Node panel.

Double-click on ‘body_entered‘ and hit ‘Connect‘:

Detecting when the bullet collides with another object in Godot

We’re going to check if the object that the bullet collided with is an enemy (by checking if the object has a method called “take_damage“), and if true, we will call the “take_damage” function and send over the damage value:

func _on_Bullet_body_entered(body):
  
  if body.has_method("take_damage"):
    body.take_damage(damage)
    destroy()

Shooting Bullets

Let us now make it so that we can shoot the bullet from the game’s weapon.

Open up the player script file (Player.gd) and create a new variable to get a reference of the bullet scene:

onready var bulletScene = load("res://Bullet.tscn")

Then we need to create a function that will be called whenever we press down on the left mouse button:

func shoot ():

In this function, we’ll create a new bullet scene node using bulletScene.instance() in a variable called “bullet”:

func shoot ():
  
  var bullet = bulletScene.instance()

Then we need to give it a parent node so it can actually exist in our main scene. We can do this by using .add_child() function:

func shoot ():
  
  var bullet = bulletScene.instance()
  get_node("/root/MainScene").add_child(bullet)

Now we need to position it and orientate it where the muzzle is at:

func shoot ():
  
  var bullet = bulletScene.instance()
  get_node("/root/MainScene").add_child(bullet)
  
  bullet.global_transform = muzzle.global_transform

We have to subtract one from our ammo as well:

func shoot ():
  
  var bullet = bulletScene.instance()
  get_node("/root/MainScene").add_child(bullet)
  
  bullet.global_transform = muzzle.global_transform
  
  ammo -= 1

Finally, we need to call the shoot function whenever we press the shoot button. We will put it inside _process() as we need to check if the shoot button is pressed every frame. Also, ensure that the ammo is greater than 0:

func _process(delta):
  
  # check to see if we have shot
  if Input.is_action_just_pressed("shoot") and ammo > 0:
    shoot()

Note that the muzzle node should be facing the correct direction. If it’s facing the wrong direction, rotate it 180 degrees on the y-axis:

Rotate the muzzle node if facing the wrong way

Save and hit Play. We’re now able to shoot bullets from our gun:

Shooting bullets from our gun in Godot

Conclusion

Well done on completing this tutorial!

For those looking to build their own FPS, this is a huge step already! You can now shoot bullets from any weapon of your choice in your Godot game – with systems that make customizing your bullet assets easy!

FPS games make great projects for beginners and experience developers alike – but there’s more to do. Expanding your project further, you can design the game environment and the player’s choice of weapons as you see fit, apart from being able to add interactable pickup items and coding the enemy AI as you’d like. There are many more directions to go, but with the core shooting mechanics done you’re on the path to success!

We wish you the best of luck in your game development journey!

Want to learn more about FPS games in Godot? Try our complete Build a First-Person Shooter with Godot 3 course.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Best Racing Game Tutorials – Cars, Tracks, and More https://gamedevacademy.org/best-racing-game-tutorials/ Wed, 25 Jan 2023 09:24:47 +0000 https://gamedevacademy.org/?p=15460 Read more]]> Nowadays there’s a huge variety of racing games out there, dating back to the first Mario Kart and coming all the way to the modern ones we have today, such as Need For Speed, Forza Motorsport, Forza Horizon, Gran Turismo, and many others. As racing games are classic, they can be very nostalgic for those who grew up playing their disparate genres, in particular arcade, kart, and simulation.

The coolest thing about coding racing games is that they are easy to start with, not to mention that we have various famous engines to suit the needs of all different levels of the required programming for such a task. That being the case, we can have a basic 2D racing game ready in about an hour and a multiplayer more advanced version in a day. So, let us now take a look at the best racing game tutorials you can follow to get you easily into coding your own games with the Unity, Unreal, Roblox, and Godot engines.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

How to Make a Driving/Racing Game in Unity

This tutorial from Jimmy Vegas teaches you how to create a driving and racing game from scratch with Unity, a very popular and powerful cross-platform engine for the creation of 2D and 3D games. Here, you’ll learn how to implement a car selection screen in order to be able to customize your car, along with the development of interesting features such as a minimap, lap count and timer, cutscenes and music, unlockables, plus a cash system. You can also choose the track you want to race in, as well as have different game modes you can play.

Topics Covered:

  • Project creation
  • Textures and car import
  • Camera angles
  • Lap count
  • Lap timer
  • Minimap
  • Car selection
  • Game modes 
  • Cutscenes
  • Race positions
  • Saving and credits

Duration: 7 hours of video training

Access now: How to Make a Driving/Racing Game in Unity

Build an Arcade Kart Racing Game – Unity

This Unity tutorial by Zenva Academy walks you through the creation of an arcade kart racing game in a style similar to Mario Kart, where players race around a track both on keyboard and controller until they complete a few laps within the specified window of time. The instructor uses Unity’s Input System to create a split-screen multiplayer game mode that you can play with your friends.

Topics Covered:

  • Project setup
  • Creating the track and environment
  • Kart movement and position
  • Camera controls
  • Split-screen multiplayer implementation
  • Countdown and winning conditions

Duration: 2 hours of video training

Access now: Build an Arcade Kart Racing Game – Unity

How to Create a 2D Arcade Style Top-Down Car Controller in Unity

With this tutorial series by Pretty Fly Games, you’ll see how to apply the physics needed for a top-down 2D racing game, including how to implement smooth movement and drift to your car. The instructor also goes over how to apply different controller inputs to each car making local multiplayer available for the game. In addition, you’ll learn how to alter the user interface to have touch input implemented for your mobile devices as well.

Topics Covered:

  • Basic game design
  • Sound effects
  • Checkpoints and laps
  • Leaderboard interface
  • Car selection
  • Local multiplayer
  • Mobile touch input

Duration: 6 hours of video training

Access now: How to Create a 2D Arcade Style Top-Down Car Controller in Unity

Unity3D Top-Down Racing Game Tutorial

In this tutorial by Stevie ROF, you’ll build a top-down racing game in Unity where you complete laps by controlling your car with the mouse cursor. Stevie explains the logic behind how to make the car drift around the custom racetrack by going over each step he’s taking with you as he’s coding.

Topics Covered:

  • Setting up the environment
  • Mouse pointer control
  • Drift implementation

Duration: 1 hour of video training

Access now: Unity3D Top-Down Racing Game Tutorial

3D Racing Game in Unity

In this Unity tutorial series from pablos lab, you’ll go over customizing and adding collision to a 3D model car to make it drift and speed on the racetrack. The presenter will teach you how to add a screen for the car selection, how to implement an AI controller for the car, show the speedometer for your car, include animations and effects such as the drifting smoke, and much more.

Topics Covered:

  • Map import into Unity
  • Camera and animation
  • Wheel colliders
  • Vehicle customization and selection screen
  • Speedometer
  • AI system
  • Drift controller
  • Adding the drift smoke effect

Duration: 4.5 hours of video training

Access now: 3D Racing Game in Unity

Low Poly Racing Game with Unity and Blender

This series from Imphenzia covers the creation of a low poly racing game with Unity that uses Blender for the modeling of the racetrack and objects of the game scene. Blender is a free and open-source graphics software used for designing animations, artworks, and 3D models.

You’ll be guided through the whole process of the game’s racetrack and visual elements making, the exporting of the models from Blender to be imported into Unity, along with all the scripting needed for the colliders’ logic, wheels, steering, checkpoints, lap system, and even best and last time tracking.

Topics Covered:

  • Importing the car model to Blender
  • Racetrack design in Blender
  • Shortcuts for the tools in Blender
  • Terrain blueprint and decoration
  • Exporting the track model from Blender to import into Unity
  • Colliders scripting in Unity
  • Checkpoints implementation
  • Lap count and timer
  • Best and last lap times

Duration: 3 hours of video training

Access now: Low Poly Racing Game with Unity and Blender

Creating a Car Game in Unreal Engine 4

In this tutorial series, Unreal Joe presents his way of designing a car game with Unreal Engine in a very easy-to-understand manner. Unreal Engine is used by many AAA game companies and also by indie developers, being a real-time 3D creation platform with photorealistic rendering and lifelike animations. Joe goes through the creation of the racetrack and landscape to menu implementation, level selection, and vehicle speedometer and sound in this quick yet very focused series.

Topics Covered:

  • Importing the car model
  • Making the track and a pitstop
  • Creating a landscape
  • Pause menu
  • Level selection
  • Speedometer
  • Adding vehicle sound

Duration: 1.5 hours of video training

Access now: Creating a Car Game in Unreal Engine 4

Create a mobile racing game in Unreal Engine

Here, Sir_Fansi Gamedev walks you through a simple project using Unreal Engine to have a racing game running on your mobile device. The instructor creates all the necessary blueprints, respawning function for the car when it gets stuck, and a checkpoint system. Moreover, he goes over the implementation of the AI logic for the other cars in the game too while continuously testing that everything still works.

Topics Covered:

  • Setting up the project
  • Creating the racetrack
  • Respawning the car
  • AI implementation for the other cars in the game
  • Checkpoint system

Duration: 30 minutes of video training

Access now: Create a mobile racing game in Unreal Engine

Fully Drivable Kinematic Car from Scratch – Unreal Engine 5 Tutorial

In this tutorial, you’ll follow Marco Ghislanzoni as he creates a kinematic car from scratch in Unreal Engine 5. He shows all the mechanics and physics you’re going to need to have a fully drivable car, testing it with you along the way. He also includes in-car camera view as well as the steering wheel animation for a more dynamic game experience.

Topics Covered:

  • Car and racetrack setup
  • Creating the car blueprint
  • Steer events
  • Adjusting the driving speed
  • Adding camera controls
  • Collision handling
  • Testing the car mechanics

Duration: 1 hour of video training

Access now: Fully Drivable Kinematic Car from Scratch – Unreal Engine 5 Tutorial

How to Make a Roblox Racing Game

Although older, this video series from Roblox gets us through the basics of building the car and racetrack in Roblox Studio, movement scripting, car respawning, the implementation of checkpoints along the game track, and ultimately the game loop logic with the Lua programming language.

Topics Covered:

  • Creating the car
  • Designing the racetrack
  • Adding checkpoints
  • Game loop
  • Building a lobby

Duration: 4 hours of video training

Access now: How to Make a Roblox Racing Game

Create Your Own Racing Game – Roblox

In this tutorial from AstrophsicaDev, the instructor shows how you can use a racing kit he made himself inside Roblox to make your own racing game by adding your own touch to the scenery and making your customized version of the game. He gives you all the instructions on how to arrange the commands for the lights and barriers spread throughout the track so you can choose your own setup.

Topics Covered:

  • Adding racing kit to Roblox
  • Custom kart
  • Safety lights
  • Starting lights
  • Kart spawn
  • Collision
  • Publishing the game

Duration: 1 hour of video training

Access now: Create Your Own Racing Game – Roblox

Godot Recipe: 3D Arcade-Style Car

Finally, we have this tutorial from KidsCanCode that uses a rigid body sphere as the basis for what will become the car object of the game, demonstrating a very simple way of implementing a 3D arcade-style car game in Godot. Godot is a free 2D and 3D, cross-platform, and open-source game engine. In this video, the instructor shows how to configure the invisible sphere that is being used as the car so that it steers, takes the turns, and goes up ramps as expected.

Topics Covered:

  • Adding a rigid body sphere to the track
  • Placing a car mesh at the location of the sphere
  • Physics configs to better control the car
  • Aligning the car with inclined road surfaces

Duration: 15 minutes of video training

Access now: Godot Recipe: 3D Arcade-Style Car

Extra Links

Unity Game Development Mini-Degree

If you’re interested in making your own games in Unity and getting to know it in depth, Zenva Academy has a Mini-Degree specifically focused on game development with Unity. Created by Unity certified developers, you’ll be creating games of the most varied genres, varying from first-person shooter to RPG, through a curriculum that counts on 25 different projects for you to hone your game designing skills using this widely known game engine.

Topics Covered:

  • Unity setup
  • Navigating the Unity Editor
  • Scripting in C#
  • Designing of level selection screens
  • 2D and 3D game techniques
  • Game audio effects
  • Procedural terrain generation
  • Cinematic cutscenes
  • Testing and debugging

Duration: 36 hours of video training

Access now: Unity Game Development Mini-Degree

Roblox Kart Racer Development Log

This video tracks the development of a kart racing game made with Roblox by Fluffmiceter based on the Mario Kart idea of throwing objects to the other karts, having to jump over obstacles or contour them, taking speed boosts, spinning around, etc. You can see the new features being added over time as well as the progress made with the camera controls, car movement, drifting, and animation effects. You can also spot some game testing too. This log is great for showing the whole evolution and making off of the scenery and the game physics and logic with each new version of the game.

Duration: 7 minutes

Access now: Roblox Kart Racer Development Log

I Made a Racing Game in 3 Days – Unreal Engine

This video from Fat Dino presents to you his journey of making a racing game in 3 days with Unreal Engine 4. He starts by modeling a simple car object then adding wheels to it, making the car move, then steering the wheels correctly by fixing them to the car with bolts.

The presenter will take you through his personalized car game design with the possibility of using weapons to target the other cars in the game and explode them. He also implements some AI for these other cars, allows car bumps, designs a nice island map for the scenery, and even creates a basic starting menu plus a car selection screen for the game. At last, he plays it with lap count and background music to a really satisfying feel of the final version of his racing game.

Duration: 12 minutes

Access now: I Made a Racing Game in 3 Days – Unreal Engine

Summary

With all that, you have plenty of resources to draw ideas from and get inspired by to start a racing game of your own! We hope you have enjoyed reading this article and that you have learned a lot from it.

There’s a myriad of options available in terms of game engines and styles that you can adhere to. It’s up to you to choose whichever suits you better or try different things until you find the one you like the most. In the end, regardless of your choice, what you can look forward to is having fun implementing it your way!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Best Roguelike Tutorials – Learning Game Dev Online https://gamedevacademy.org/best-roguelike-tutorials/ Wed, 25 Jan 2023 08:32:40 +0000 https://gamedevacademy.org/?p=15561 Read more]]> Roguelikes are not only a popular genre of videogames, but they’re one of the most interesting as well. Focusing more on replayability and randomized worlds rather than tightly-structured level design, they provide players and developers with the chance to explore a wide variety of interesting mechanics through ever-shifting game worlds.

If you’re interested in creating your own roguelike games, we’ve put together this handy list of online tutorials that provide a perfect starting point for you to learn the essential game mechanics and programming skills you’ll need to succeed. 

Why Should You Learn To Create A Roguelike?

Roguelikes are a slightly more niche genre than others, but they still have plenty to offer to both players and developers. Recent hits like Hades and Darkest Dungeon prove that this genre can be used for extremely inventive gameplay and innovative storytelling, which makes roguelikes a very interesting project for game developers in-training to work on.

Roguelikes are often characterized by a randomized, procedurally generated game world that changes with every new playthrough. Learning procedural generation can be a valuable skill for game developers; as well as roguelikes, it can be applied to survival games, simulations, sandboxes and more. 

In addition to procedural generation, roguelikes give developers a chance to work with a variety of other game mechanics as well. Action-oriented roguelikes can help you to practice character movement, enemy scripting and combat mechanics, while roguelikes with RPG elements can help you to learn more about turn-based combat, stat systems, and game balance. 

Basically, roguelikes are a highly adaptable genre that you can use to practice new mechanics and experiment with systems from different genres, all while creating a fun and highly replayable gaming experience. As such, they make for great projects for beginners and more experienced game developers alike.

Roguelike Game Online

If you’re ready to get stuck into your first roguelike project, then the following list of tutorials will give you plenty of potential starting points. From dungeon-crawlers to survival games, these tutorials cover a variety of niches within the roguelike genre and will help you to build a range of essential skills to make a successful roguelike of your own.

Roguelikes are naturally slightly more complex than other genres, but we’ve made sure to include several tutorials in this list that are perfect for beginners as well as more experienced developers. 

The Complete 2D Roguelike Course

If you’re looking for somewhere to start your roguelike development journey, then there are few better options than this comprehensive tutorial from Zenva Academy. The Complete 2D Roguelike Course is a detailed introduction to the genre, exploring the fundamentals of roguelike development and guiding you through the process of making your first roguelike.

The tutorial walks you through a step-by-step guide to creating your own 2D dungeon-crawling roguelike in Unity. You’ll learn to procedurally generate dungeons, create enemies, code items and powerups, and more, all while learning a variety of skills that can help you to flesh out future projects with all sorts of new features. 

All you need to get started is a basic understanding of Unity and C#, making this tutorial a fantastic option for beginners. Even if you already have plenty of experience with the Unity platform, The Complete 2D Roguelike Course is still definitely worth taking – you’ll learn a range of useful skills for other projects and master a new genre at the same time as expanding your portfolio with a new game.

Key Topics Covered:

  • Creating random dungeon maps through code
  • Generating randomized dungeon room interiors
  • Implementing enemies and a simple battle system
  • Adding health and gold pickups with UI
  • Controlling gameplay flow with keys & doors
  • Setting up a mini-map system

Duration: Just over 3 hours of video tutorials explaining the entire process of building a 2D dungeon-crawler roguelike.

2D Roguelike Project

Another option for learning to make your own 2D roguelike in Unity comes from Unity itself in the form of the Unity 2D Roguelike Project tutorial series by Unity itself. These tutorials guide you through the process of creating a simple 2D roguelike where the player character must search for food and survive a wasteland for as long as possible.

The game project is turn-based and tile-based, with each tutorial teaching you to add new elements like level randomisation, enemies, audio and more. By the end of the series you’ll have mastered a variety of fundamental game mechanics for the roguelike genre and be ready to implement these systems into your own games to create your own roguelike. 

Key Topics Covered: 

  • Animating and moving the player character
  • Using tile prefabs 
  • Board and game managers
  • Moving objects and walls 
  • Player and enemy scripts
  • UI design
  • Level creation and transitions
  • Audio
  • Mobile controls 

Duration: A series of shorter tutorial videos lasting roughly 2 hours.

Build A Roguelike Game With C++ And SFML

Another option for roguelike development from Zenva is the Build a Roguelike Game with C++ and SFML tutorial. This tutorial works along similar lines to the 2D Roguelike Course, except it uses the Simple and Fast Multimedia Library rather than Unity, so if you’re not keen on using Unity then this is an ideal alternative. 

The tutorial guides you through the process of using SFML’s multimedia capabilities to build a 2D action-oriented roguelike where players must dodge moving enemies to reach the exit in each level. By the end you’ll have created your own version of the project, learning various skills such as user interaction, adding graphics, building dungeons and more along the way.

You’ll need some existing familiarity with the C++ language and SFML to get started with this project, but with a simple step-by-step structure, it’s easy to follow and perfect for beginners. It also makes for a fun project for more experienced developers who want to learn to use new tools, since the course acts as a great introduction to both C++ and SFML.

Key Topics Covered:

  • Setting up SFML game projects
  • Drawing sprites to the screen
  • Constructing tile-based maps with C++
  • Detecting user input for player movement
  • Moving enemies to available spaces randomly
  • Implementing logic for ending the game

Duration: 2 hours of video tutorials explaining how to make a 2D roguelike in SFML.

How To Create A 2D Roguelike Game

The How To Create A 2D Roguelike Game tutorial series from Dapper Dino provides another great entry point for game developers who are curious about dipping their toes into the roguelike genre. Like many of the other tutorials on this list, the tutorial focuses on using Unity to implement the various mechanics and systems that are commonly found in roguelike games.

The tutorial takes inspiration from the roguelike game Wizard of Legend, using it as a reference point for which systems to include in your own roguelike. Following the tutorial, you’ll steadily build up your own simplified roguelike in the style of Wizard of Legend, mastering core mechanics like combat, loot drops, class systems, map generation and more.

You’ll need some existing knowledge of Unity and C# to ensure you understand each part of the tutorial, but it does a good job of providing step-by-step instructions at each stage, so it’s fairly accessible even if you’re more of a beginner than a pro. 

Key Topics Covered: 

  • Creating a menu
  • Importing spritesheets and setting up character movement
  • Setting up animations and transitions
  • Creating health and stat systems
  • Programming simple spells and combat actions
  • Camera movement and controls 
  • Dashing mechanics
  • Collectible items including currency and loot drops
  • Currency UI 
  • Class systems 
  • Enemy spawning systems 

Duration: Just under 4 hours of video tutorials, each exploring different mechanics in the roguelike genre.

2D Procedural Maps For Beginners

If you’ve already worked on a few different game projects and want to try your hand at a roguelike next, but don’t want to have to sit through a tutorial covering game design fundamentals you’ve already learned, then this may be the tutorial for you. 

The 2D Procedural Maps for Beginners tutorial is a shorter tutorial series that provides step-by-step instructions for creating procedurally generated 2D game maps in Unity. You’ll learn the expandable programming logic needed to create these maps, plus key systems like noise maps, biome calculations, player controllers, and more.

Once you’ve used this tutorial to master procedural generation, you’ll be all set to implement these systems into your projects, allowing you to build roguelikes from the ground up or add randomized worlds into other projects to give them a roguelike twist. 

Key Topics Covered: 

  • Generating noise maps in Unity
  • Understanding noise settings for different effects
  • Calculating biomes based on noise map data
  • Organizing biome data with Scriptable Objects
  • Instantiating 2D tiles based on biome data
  • Implementing a player controller

Duration: 1 hour, 30 minutes of video tutorials explaining each step in creating procedurally generated maps in Unity.

Roguelike Python Tutorial

If you’re unfamiliar with Unity or C# and would like to learn to make a simple roguelike without using these, then another option is to follow the Roguelike Python Tutorial from Ombarus. This series guides you through the process of creating a very basic roguelike using standard keyboard symbols to represent the map and characters, giving it an appearance similar to the original Rogue game that the genre is named for. 

The tutorial follows the structure of the text-based 2020 Roguelike Tutorial, meaning you can refer to a written guide if you get stuck at any point. Through the course of the tutorial series, you’ll learn to create and control a player character, generate randomized maps, implement a turn system and more, allowing you to get to grips with many of the core mechanics of the roguelike genre.

While this tutorial leads to a much more simplistic finished project than some of the other options on this list, it’s still a fun way to learn more about the systems used in roguelike games, and it provides a fun entry point for coders more familiar with Python than Unity. 

Key Topics Covered: 

  • Setting up and controlling a player character
  • Generating random maps and enemies
  • Adding a field of view system
  • Adding a turn system 
  • Coding combat systems and UI
  • Adding interactable items, spells and other actions
  • Saving the game
  • Creating multiple levels
  • Balancing the game and adding equipment

Duration: Roughly 2 hours, 45 minutes of video tutorials covering each stage of creating a simple Python-based roguelike.

The Complete Procedural Terrain Generation Course

While the majority of the roguelike genre is made up of 2D games, there are no rules against using a 3D environment for your roguelike, especially when blending your roguelike with other genres. Recent hits like Returnal have shown that blending the random elements of the roguelike genre with 3D environments and fast-paced action can be a winning combination.

So, if you want to try your hand at creating your own 3D roguelike, the best place to start is to understand how procedural generation works in a 3D environment in order to craft random levels for your players. The Complete Procedural Terrain Generation Course allows you to do just that, teaching you the fundamentals of using procedural terrain generation to create randomized maps complete with varied biomes. 

The tutorial will help you learn to algorithmically generate a terrain’s shape with C# in Unity, and also provides a guide to performance optimization to ensure a smooth playing experience in your randomised world. You’ll need a basic understanding of Unity and C# to get started, but otherwise, this step-by-step guide is extremely accessible and beginner-friendly.

Key Topics Covered:

  • Generating noise maps to determine the shape of the terrain
  • Utilizing noise maps as height maps to produce terrain
  • Applying gradient textures to a mesh based on terrain shape
  • Setting up heat maps and moisture maps based on the terrain height
  • Combining various data elements to algorithmically determine biomes
  • Using biome types to determine how trees spawn

Duration: Roughly 3 hours, 40 minutes of video tutorials explaining the process of procedural terrain generation using Unity.

Conclusion

Roguelikes provide aspiring game developers with an exciting and unique challenge, tasking them with creating fun and replayable gameplay within randomized levels and worlds. As such, they’re a perfect next step for those who have completed a few different projects and want to tackle a more complex genre next. 

Using the tutorials above, you should be able to master many of the core mechanics found in roguelike games. Whether you choose to create your own roguelike or implement roguelike mechanics within your other projects to give them a new and unique twist is up to you!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Best Survival Game Tutorials – Making your own Video Game https://gamedevacademy.org/best-survival-game-tutorials/ Wed, 25 Jan 2023 08:17:33 +0000 https://gamedevacademy.org/?p=15486 Read more]]> Survival games offer a challenging and unique niche within the gaming world, tasking players with fighting off hunger and thirst as much as fighting enemies. Survival games are also a popular genre for multiplayer gaming, giving you the thrill of working alongside your friends to survive hostile environments.

Because of all this, survival games are a popular choice as a first project for budding game developers. However, creating a survival game means mastering a variety of skills, concepts and game mechanics, such as base-building, character needs, crafting and more. As such, it’s often helpful to start with a guided project or tutorial.

To that end, we’ve put together a list of some of the best survival game development tutorials to help you learn the foundations of the survival genre and create your very own survival game to add to your portfolio.

Why Should You Learn To Make A Survival Game?

Famous survival games like Minecraft, ARK: Survival Evolved, DayZ and more are hugely popular thanks to their often open-ended game structure and the challenges involved in managing your character’s needs to keep them alive. This popularity means there’s a huge audience just waiting to try out your own survival game!

Aside from the genre’s popularity, survival games are also a great way to learn a variety of game mechanics and systems that can help you to diversify other projects with new gameplay features. Hunger and thirst meters, crafting systems, base-building and day/night cycles that affect enemy spawns and behavior are all great tools for enhancing your future game projects.

Survival games also offer a great deal of freedom in terms of their style and core gameplay mechanics. They could focus on shooter elements like in DayZ or turn into more of a sandbox game like Minecraft, for example. The genre also lends itself well to both 2D and 3D environments, giving you a huge amount of choice when it comes to appearances and playstyles.

Best survival game tutorial

To help you on your journey to becoming a survival game master, we’ve compiled a list of some of the best online tutorials available for making your very own survival game from scratch. 

Many of these are geared towards beginners, with step-by-step instructions to build a survival game from the ground up. However, more experienced developers looking to learn new skills and mechanics they can use on advanced projects will also get a lot of use out of the tutorials below.

Survival Game Development Academy

If you’re looking for a comprehensive guide to the survival genre’s core systems and mechanics, look no further than this comprehensive tutorial from Zenva Academy. The Survival Game Development Academy course provides a detailed guide to everything you need to know to go from a complete novice in survival game design to an experienced pro.

The tutorials in this course explore survival game development in the Unity engine, covering all the key topics you need such as item crafting, base building, player needs, combat and more. As well as equipping you with the skills to make your own fully-fledged survival game, these concepts and systems can also be applied to projects in other genres to add your own unique spin on classic formulas.

This course even covers the very basics of C# coding and using the Unity Editor in its first module, so it’s a perfect starting point even if you have no prior coding experience at all. The detailed guides in this course are also perfect for more experienced coders looking to learn new skills.

Key Topics Covered:

  • Hunger, thirst, health, and sleep needs
  • Day-night cycles
  • Item and inventory systems
  • Crafting mechanics
  • Base building
  • Combat and Enemy AI
  • Game Saving

Duration: 18 hours of video tutorials on a comprehensive range of survival game subjects, split across 6 “levels” (modules).

Survival Game Player Mechanics For Beginners

If you’re looking for a slightly shorter introduction to the survival genre, then this alternative Zenva course may be more appealing. The Survival Game Player Mechanics For Beginners tutorial is a great place to start for those who have some prior coding or game development experience but who are new to the survival genre’s mechanics. 

The tutorial provides a step-by-step guide to creating survival games in Unity, starting with fundamental mechanics like movement and player controls. It then moves onto survival-specific elements like player needs, health, day/night cycles and more to create the foundations of your own survival game. 

These concepts can help you to build out your own survival game or to add new mechanics to other game projects further down the line. You’ll need a basic understanding of C# and Unity, but other than that there are no strict prerequisites, making this a perfect place to start your survival game journey.

Key Topics Covered: 

  • Implementing basic player movement
  • Setting up a first-person camera
  • Creating a needs system for hunger, thirst, and sleep
  • Managing health with damage indicators
  • Building a basic 3D terrain
  • Controlling lighting to mimic a day-night cycle

Duration: 2 hours, 30 minutes of video tutorials covering various key Survival mechanics.

Create An FPS Survival Game In One Video

Another great option for learning some of the basics you’ll need to lay the foundations of your survival game is the Create An FPS Survival Game In One Video tutorial from YouTuber Awesome Tuts

This video provides you with a step-by-step guide to creating your very own FPS survival game, along with all the game assets you’ll need to follow along and build the project yourself. The tutorial focuses on the Unity engine and merges survival with FPS mechanics to teach a wide range of game mechanics and systems at once. 

It starts with world design elements like lighting and ambience, then moves on to basic player controls and movement. After this, the tutorial explores various subjects like weapons, enemy animation and behavior, health systems and more.

Unfortunately, the tutorial does omit certain core survival features like crafting and base building, so those looking to create a more traditional survival game may choose to look elsewhere. However, it’s a great starting point for anyone intending to make a more action-oriented survival game.

Key Topics Covered: 

  • Lighting and ambience
  • Creating a player character and coding movement
  • Programming weapons and shooting/attacking
  • Configuring, animating and coding the behavior of enemies 
  • Enemy spawning systems
  • Healthy and stamina systems
  • Player UI
  • Sound effects 

Duration: One video lasting just over 8 hours, 10 minutes, split into different sections for each subject

Discover Base Building For Survival Games

If you’re someone with slightly more experience with game development who just wants to learn some of the core aspects of the survival genre, then this shorter tutorial may be the one for you. The Discover Base Building For Survival Games tutorial covers the base building mechanics commonly found throughout the survival genre. 

Like most of the tutorials in this list, this one focuses on using Unity to implement base building elements in your games. Since crafting is often a core component of base building (and survival games more generally), the tutorial covers these systems in addition to the building mechanics that will allow your players to set up base structures in the game environment.

There are also guides to common base functions like sleeping in beds to heal or pass in-game time, ensuring your base has all the functionality that players would expect. 

This tutorial is an excellent option for slightly more experienced developers who are looking to add core survival mechanics to their skillset to enhance future projects. It’s equally suitable for beginners, since it only requires a basic understanding of Unity and C#; however some familiarity with the basics of game design and other survival game elements may be helpful.

Key Topics Covered: 

  • Controlling when base-building mode is active
  • Combining crafting systems with base-building
  • Selecting different building objects to be placed
  • Detecting applicable building locations
  • Implementing sleep functionality with beds
  • Creating interactive, light source campfires

Duration:  Roughly 1 hour, 45 minutes of video tutorials.

NPC AI And Combat For Survival Games

One of the key elements of the survival genre is the presence of other characters and enemies that the player can interact with or fight against. The NPC AI And Combat For Survival Games tutorial shows you how to enhance your survival game with animated NPC models that can flee from players, attack them, chase them, drop items and more.

It also includes an additional guide on how to enhance the appearance of your game with post-processing effects that can give your game its own distinctive look and feel. This is a great way to make your game feel more polished and impressive, making it a strong addition to your portfolio. 

You’ll only need a basic understanding of Unity and C# to complete this tutorial, making it fairly accessible for beginners. However, it may be useful to have learned some of the basics of survival game design to provide a stronger foundation to work from in this tutorial.

Key Topics Covered:

  • Creating a multipurpose NPC class
  • Setting up a NavMesh for navigation
  • Controlling NPC actions with a state machine
  • Implementing combat and loot drops
  • Applying animations to NPCs
  • Adjusting aesthetics with post-processing effects

Duration: About 1 hour, 50 minutes of video tutorials.

Conclusion

The survival genre is a unique opportunity for budding game designers to learn new mechanics while merging in aspects from other genres like FPSs, RPGs, and action-platformers. This is part of the genre’s appeal – it allows a lot of creative freedom at the same time as providing a solid challenge and engaging gameplay to players.

By following the tutorials above, you’ll gain a deeper understanding of survival mechanics and learn to implement them in your own projects. We hope you’ll have fun crafting your own unique spin on the survival genre using these handy guides and tutorials!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Create a Third Person Camera for Action RPGs in Unreal https://gamedevacademy.org/unreal-engine-camera-tutorial/ Sun, 06 Nov 2022 01:00:27 +0000 https://coding.degree/?p=472 Read more]]>

You can access the full course here: Build an Action RPG in Unreal Engine

Player Setup

Creating the Player Blueprint

In the Blueprints folder, create a new blueprint of type Character called Player.

Player blueprint in Unreal Engine Content Browser

Double-click to open it up inside of the blueprint editor. You’ll see that we have a number of default components. These help us out with creating our player. To begin, select the Mesh component.

  • Set the Skeletal Mesh to PlayerModel
  • Set the Location to 0, 0, -90
  • Set the Rotation to 0, 0, -90

Character in Unreal Engine with model added

Next we’ll create the damage collider. Create a new Box Collision component as a child of the mesh component. Rename it to DamageCollider.

Damage Collider added to Player's Components

  • Set the Location to -20, 90, 110
  • Set the Box Extents to 25, 32, 32
  • Set the Collision Presets to Trigger (not pictured)

Unreal Engine collider added for damage detection

Now we need to create our camera which will follow the player. This will be done by using a spring arm. This is a component which connects the camera to the player and also allows for collision detection. Create a new Spring Arm component.

  • Set the Location to 0, 0, 70
  • Set the Rotation to 0, -20, 0

Player in Unreal Engine with SpringArm component added

As a child of the SpringArm component, create a new Camera component.

  • Set the Location to 0, 0, 70
  • Set the Rotation to 0, -20, 0

Camera added to Unreal Engine scene

We can then click compile, save then return to the level editor. In order for the game to know what our player is, we’ll need to create a new blueprint of type GameMode Base called MyGameMode. Open it up and inside, set the Default Pawn Class to Player. Save, compile, then return to the level editor.

Player Blueprint set as Defualt Pawn Class in Unreal

To assign this game mode, go to the Details panel and click on the World Settings tab. Here, set the GameMode Override to MyGameMode.

Unreal Engine World Settings

Now when you press play, you should see the player spawn in, with us looking through the camera.

Camera Setup

Orbiting the Camera

In this lesson, we’re going to set it up so that we can rotate the camera around the player with our mouse. Inside of the Player blueprint, let’s go over to the Event Graph. First, we want to create a new event node called Mouse X. This gets triggered when we move our mouse and it outputs the horizontal axis value.

Plug this into an AddControllerYawInput node like below.

Mouse X attached to Yaw Input in Unreal Engine Blueprint

Compile, save and press play. You’ll see that we can move the mouse horizontally to rotate the player.

Now let’s rotate the camera up and down. We can’t do it like before since this will rotate the player sideways. Instead, we want to set it up like this:

Mouse Y, Rotater, and Spring Arm attached to Local Rotation

One problem with this, is that the camera can rotate all the way around the player. To fix this, we need to clamp the vertical rotation. To begin, we want to set the spring arm rotation after we add to it.

SetRelativeRotation circled in Unreal Engine

To clamp, let’s start by getting the target rotation of the spring arm and breaking it.

Node setup for getting target rotation in Unreal Engine

Connect this to a Clamp Angle node.

  • Set the Min Angle Degrees to 45
  • Set the Max Angle Degrees to 20

Clamp Angle node added in Unreal Engine

Then we can plug that result into the Y of a make rotator node, and plug that into the set rotation node.

Make Rotator Node circled in Unreal Engine

Now you should see the camera rotation is clamped vertically.

 

Transcript

Player Setup

Welcome back everyone. In this lesson we are going to begin to create our Player Blueprint. This is gonna be featuring our Player model, it’s gonna to be featuring the colliders, the camera, everything we need in order to have our Player set up and ready to go.

So inside of our blueprints folder here, I’m gonna right click and create a new blueprint class. This is gonna be of type character, which basically gives us some preset things such as a Capsule Collider, a Mesh, a forward Direction, and also includes a Character movement Component which allows us to easily set up the player movement, the camera rotating, jumping, ground detection, and many other movement related things.

So it will create a character right here and we are gonna call this one player. We can then double click to open this up inside of the Blueprint Editor. I’m gonna dock it to the main window here. And as you can see here, we have a few things set up already for us. We have a capsule component here, which is collider, we have an arrow component, this is this blue arrow right here. And this just defines the forward direction. We have a mesh, which is going to be our Player mesh which we can then animate later on. And the character movement component, which as you can see here in the details panel includes a lot of different options we can tweak in order to find sharing our movement, okay?

So the first thing we’re gonna be doing is setting up a mesh. So I’m gonna select our mesh here, and I’m gonna select the skeletal mesh, and I’m gonna change this to our Player model right here. So there we go. We’ve got our Player model now in here, but it doesn’t really match the bounds or the direction of this capsule, we need to rotate it and move it down a bit. So I’m gonna set the Z location to be negative 90, so it is down in the correct position.

And now we just need to rotate it negative 90 on the Z as well, so it is facing in the correct forward direction it’s facing in its positive X direction luxor, okay? So we’ve got our player mesh there. Now what we need is the damage collider and the damage collider is basically going to be a collider that’s gonna check to see if there are any enemies inside of it when we are attacking.

So as a child of mesh, we can just select mesh here to arrow component and I’m gonna type box collision. And I’ll just call this one our damage collider luxor. And in terms of positioning it, we can just lift it up here, move it forward a bit and have it about there. So over here where we have the box extents, I’m gonna change this to be 25. And let’s also position it to the left a bit since that’s where the weapon is. Make sure it’s around in line like so and there we go.

Okay, so along with this, we also want to make sure that it is not a solid collider it needs to be a trigger that objects can move through. So down the details panel, let’s make sure generate overlap events is enabled. And let’s change the collision presets from overlap all dynamic to trigger okay, there we go.

Now what we can do is set up the camera. And the way we’re gonna do the camera is by attaching it to something known as a spring arm. And a spring arm is a very handy component which basically sets its child object or its child component a fixed direction and distance away from it. So what we can do then, is just rotate the spring arm and the camera is gonna rotate around our player.

So I’m gonna go add component, I’m gonna look for a spring arm. Make sure it is a child of the capsule component and not the mesh. So with this spring arm now, all we need to do is go to the details panel and change a few things.

First of all, we are on the point of orbit not to be around the waist of our player but probably up oops, probably up over near the players head right here. So to drag that up to the head there, we’ll set the wire rotation to be 20. Oh, negative 20 I mean, so we do have a bit of a downwards facing camera when we start off. And apart from this, we can leave everything as it is.

So what we’re gonna do now is as a child of spring arm, we’re gonna add component, we’re gonna look for camera, there we go. So now we got our camera in here, it is going to be right at the end of the spring arm as you can see here.

Now for our camera, what we want to do is move it over just a little bit to the right because since this is gonna be a third person controller, we probably don’t want the camera directly behind the play as that might sort of obstruct the view a bit. So normally what other games do, is they move the camera over to one of the sides a bit. So I’m gonna move this camera to be 60 on the Y location so it’s a bit to the right of the player.

And that is pretty much it. So if you select the spring arm on here, and we press E to get the rotation gizmo, you’ll see that if I rotate it, the camera follows along as well. Okay, so now what we can do is click save, click compile, we can go back to our main level here.

And we can set it up so that when we press play, our Player spawns in because right now if we press play, the play is not there, we just have controlled the default camera anchor, which just allows us to fly around similar to the main viewport.

So what we need to do is create a game mode so that it knows the default things such as the default player to spawn at the started level. So let’s right click here in the blueprint class, we’re gonna create a new blueprint. This one is gonna be a game mode base. And a game mode base basically defines some of the defaults, again such as the player, the default UI, the default multiplayer aspects, okay?

So we’ll go game mode base, I’m gonna call this one my game of mode. We can double click to open this up, this is also a blueprint. So we don’t actually have to add anything here if you do want some sort of global logic for your level, then you can probably add it to the event graph here, but we’re just gonna leave it as it is. And over in the details panel, we want to make sure that we have the default pawn class here. We want to change that our Player right here, okay? That’s all we need to do.

So we can click compile, we can click save, we can close out of the game mode here, I’m also gonna close out our project settings. And in our main level here, let’s go over to the world settings tab, which is inside of the details panel here, and world settings basically, global settings for the current level. So we can change things such as air game mode override. Right now it’s on none which means there’s no game mode active. So let’s select that and choose my game mode.

So now when we press play, the game is gonna look at the game mode and go okay, what is the default player class to spawn? It’s gonna see it is our Player blueprint. So it is gonna spawn the player blueprint in on this player start position right here. So we can press play and there we go.

This is our player blueprint setup, it’s spawning in. Now all we need to do is implement the functionality to actually look around with the mouse rotate the camera and move around with the keyboard. So we are gonna be beginning on setting up the camera orbiting in the next lesson. So I’ll see you all then.

Camera Setup

Welcome back everyone. In this lesson, we are gonna be setting up the camera orbiting system, for app play blueprint here. In the previous lesson, we set up the play blueprint, so it has all the components set up ready to go. We also have this spring arm component, which if we go to the rotation tool, we can rotate it around, which has the camera then orbiting around the player. Okay?

So in this lesson, we’re gonna make it so that whenever we move our mouse, the camera rotates around a player.

So, let’s go to the event graph here, and what we’re gonna do is start off by deleting these three nodes that are here by default, so that we have a blank canvas here, and to begin, we’re gonna set up the horizontal movement. So, when we move the mouse left or right, the camera is gonna rotate left to right around the player.

And to do this, I’m gonna right click, and I’m gonna go mouse X, and you’ll see that we can get mouse events. We want to get the mouse X input event. And what this means, is pretty much whenever the mouse moves, this gets triggered and it sends over an axis value of the current map of the current horizontal mouse movement. Okay? So, this value ranges from negative one to one, negative one, meaning the mouse is moving left, one, meaning the mouse is moving right, and zero, meaning the mouse isn’t moving at all.

But with this, we aren’t actually gonna be rotating the spring arm or the camera, instead we’re going to be moving the entire player, left or right. We’re gonna be rotating them around, because, when we move around, we want the player to always be facing in the forward direction that the camera is.

So, we’re gonna drag off from here, and, we are gonna go to the add controller, your input node right here. And what this does is, this adds a certain value to our control is your input, which is the vertical rotation. So if we plug access value into the value input, that is all we need to do. And this is a node here, that is set up for us by this character movement component. This involves all of the movement, variables and properties that we can modify.

So if we save this compile press play, you should see that when we moved the mouse left and right, the character rotates to face the forward direction. So no matter where we look the player’s always rotating with us as we move the mouse. Okay?

So, we got the left and right movement, but, what about the up and down? Well, that’s a bit different because with this, we are gonna be rotating the spring arm. We don’t want to rotate the entire player, because that will look a bit weird so, we can be irritating the camera up and down. Okay? So, what we’re gonna do for that, is just like getting mouse X.

We now need to get mouse Y, so, mouse events, mouse Y here. And this trick is when we moved the mouse up and down, axis value again ranging from, a one being moving the mouse up, and negative one being moving the mouse down. And, we want to plug this into an add local rotation. Add local rotation. On the spring arm component here. Okay? There we go, creates that.

So, what we’re doing here is, we are gonna add a rotation to the spring arm, and that rotation is going to be along the Y axis. And the Y axis, if we go to the viewpoint here, select the spring on. The Y axis, is this green one here. So we can move this up and down, so the camera goes like so.

Okay. So, in event graph, to do that, what we’re gonna do is right click, and create a new node called make rotator. This basically creates a rotation for us, which we can then plug into, this add local rotation node like so, and X value, we are gonna be plugging into the Y axis here, on the micro data node. So, basically it was sending over a delta rotation, which is gonna be added on to the existing spring arm rotation.

So, if we press play, you’ll see that we can move left and right, but we can also move up and down. Like so. But something you may notice, is that if we keep moving down, our camera just keeps going around, and we can actually go 360 degrees, which isn’t probably what you want.

And something else you may also notice, is that when the camera goes down, and it hits the ground, it sort of moves towards the player. This is really cool, as the spring arm already has included with it, basically detecting if there’s anything between, the start of the spring arm and the camera. So if there’s anything between it, it pretty much snaps the camera, so, it is always looking at the plan. Nothing can ever get in the way between the camera, and the player. Which is really good. Okay?

But we still need to fix the issue of actually being able to rotate all the way around like this, as it may be very disorientating, to use as the player. So, what we need to do for this is clamp the rotation. And clamping the rotation basically means, we get the Y axis here, the Y rotation, and, we want to make sure that it never goes below a certain number, and never goes above a certain number.

So to do this, I’m gonna plug this add local rotation node, into a set relative rotation for the spring arm. So after we add the rotation to this spring arm, we then want to set it, so that is, make sure it’s in between two certain values. So over here, what we’re then gonna do, is create the get targets rotation node on the spring arm. And this year basically just returns to us the rotation of the spring arm currently.

So, we wanna get that. And then we want to plug this rotation here into a break rotator node. And what this does, is pretty much the exact opposite of make rotator. Instead of creating a rotation, it gets a rotation and breaks it up into each of the individual axis, which we can use. Now, since a vertical rotations are only dependent on the Y axis, we’re gonna get this, and we are gonna plug this into a clamp angle node here.

Okay. And this clamp angle node, has a few things. First of all, it has the actual angle that we are inputting into it, which is our Y axis. And then we have a min angle degrees, and a max angle degrees. And these are basically the min and max values that these angle can possibly be. So, the minimum rotation, we’re gonna have it at about 45 degrees, and the max rotation, we are gonna have it at 20. Okay. You might wanna tweak these numbers a bit, as we continue on, as you may want it a bit higher, you may want it a bit lower. Okay. So we got this value here.

Now we need to make it into a rotator again, so we can plug it into this set relative rotation node, so we’re gonna put this into make rotator, we actually wanna delete this connection, and make sure it was connected to the Y axis here. And, then we can just plug that into the new rotation input, on the set relative rotation node. And there we go. So this is pretty much it, in order to set it up so that it clamps the rotation. So it can’t get too high, or too low, let’s now press play and see if it works.

So here we go, we can rotate left and right. And if I moved down, you’ll see that it stops, when I reach here. I can no longer move the camera down anymore. I can move it up and it stops here. So I can’t move it up anymore either. So there we go. We’ve got our camera rotation set up. We can rotate left or right, we can rotate up and down, and, that is all good.

So, in the next lesson, we are going to be looking at actually setting up app play movement. So that we can actually start moving around, jumping, and then later on, setting up the abilities to actually attack.

Okay. Now before we go real quick, I’m gonna probably put these in some comments, so that they’re a bit neater. So, I’m gonna get these here, select these two nodes, right click, go create comment from selection, and I’m gonna call this one our camera, rotate, (keyboard clicking) camera rotates, horizontal. (keyboard clicking) Okay. We can then readjust these, like so, shrink this down a bit. It’s really good practice to actually, comment your nodes as later on, once you have many, many new nodes in your project. It may be quite hard to understand what you shouldn’t do, especially if they’re all messy, like this right here. So I’m just gonna tidy them up a bit.

We can then select them again, and, I’m gonna right click, create comment from selection, and this one is going to be called, our camera rotate vertical. All right. We can always select these again, readjust them to a position where we want them, and, there we go.

Okay. So yeah, overall, make sure you do comment your nodes, we’ll be doing this again in the future, for a movement for our jumping. Just so you can see what each of the different segments here are, at a quick glance. Okay. So, thank you for watching. And, I’ll see you all in the next lesson.

Interested in continuing? Check out the full Build an Action RPG in Unreal Engine course, which is part of our Unreal Game Development Mini-Degree.

]]>
How to Create a First-Person Shooter in the Unreal Engine https://gamedevacademy.org/unreal-engine-fps-tutorial/ Fri, 03 Jun 2022 01:00:23 +0000 https://gamedevacademy.org/?p=11964 Read more]]> Whether you’re a fan or not, there’s no denying that first-person shooters are a popular game genre.  Thus, it can be beneficial to know how to make one, whether it’s just to round out your own skills or to create that FPS game idea you’ve had haunting your dreams.  It can be even more beneficial to learn how to do this with Unreal Engine, the popular and graphically stunning engine behind a ton of popular games.

In this tutorial, we’re going to show you how to create a first-person shooter game inside of the Unreal Engine. The game will feature a first-person player controller, enemy AI with animations, and various shooting mechanics.  We will also cover the Unreal Engine blueprinting system for the logic, so no other coding knowledge is needed.

So, without further ado, let’s start learning how to build an FPS with Unreal Engine!

Unreal Engine FPS game in GIF form

Project Files

There are a few assets we’ll be needing for this project such as models and animations.  You can also download the complete Unreal project via the same link!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

Project Setup

Before we start though, it’s important to know that this tutorial won’t be going over the basics of Unreal Engine. If this is your first time working with the engine, we recommend you follow our intro tutorial here.

To begin, create a new project making sure to include the Starter Content. This should then open up the Unreal Engine editor. Down in the Content Browser, create four new folders.

  • Animations
  • Blueprints
  • Levels
  • Models

Unreal Engine Content Browser window

Next, download the required assets (link at the start of tutorial). Inside the .ZIP file are three folders. Begin by opening the Models Folder Contents folder and drag all the folders inside of that into the Models folder in the Content Browser. Import all of that.

Then do the same for the Animations Folder Contents. When those prompt you to import, set the Skeleton to mutant_Skeleton. The mutant model and animations are free from Mixamo.

Unreal Engine Import Options with mutant skeleton selected

Finally, drag the FirstPerson folder into the editor’s Content folder. This a is a gun asset that comes from one of the Unreal template projects.

Unreal Engine with FirstPerson folder added to Content Browser

Now we can create a new level (File > New Level) and select the Default level template. When the new level opens, save it to the Levels folder as MainLevel.

Unreal Engine with new level scene

Setting Up the Player

Let’s now create the first-person player controller. In the Blueprints folder, create a new blueprint with the parent class of Character. Call it Player. The character parent includes many useful things for a first-person controller.

Unreal Engine with Player blueprint added to content

Double click it to open the player up in the blueprint editor. You’ll see we have a few components already there.

  • CapsuleComponent = our collider
    • ArrowComponent = forward direction
    • Mesh = skeletal character mesh
  • CharacterMovement = movement, jumping, etc.

Unreal Engine components for Player object

We can start by creating a new Camera component. This allows us to see through our player’s eyes into the world.

  • Set the Location to 0, 0, 90 so that the camera is at the top of the collider.

Unreal Engine camera for FPS player

For the gun, create a Skeletal Mesh component and drag it in as a child of the camera.

  • Set the Variable Name to GunModel
  • Set the Location to 40, 0, -90
  • Set the Rotation to 0, 0, -90
  • Set the Skeletal Mesh to SK_FPGun
  • Set the Material to M_FPGun

Unreal Engine with gun object added for FPS

Finally, we can create the muzzle. This is a Static Mesh component which is the child of the gun model.

  • Set the Variable Name to Muzzle
  • Set the Location to 0, 60, 10
  • Set the Rotation to 0, 0, 90

We’re using this as an empty point in space, so no model is needed.

Unreal Engine Details for gun object

That’s it for the player’s components! In order to test this out in-game, let’s go back to the level editor and create a new blueprint. With a parent class of Game Mode Base, call it MyGameMode. This blueprint will tell the game what we want the player to be, etc.

In the Details panel, click on the World Settings tab and set the GameMode Override to be our new game mode blueprint.

Unreal Engine World Settings windows

Next, double-click on the blueprint to open it up. All we want to do here is set the Default Pawn Class to be our player blueprint. Once that’s done: save, compile, then go back to the level editor.

Unreal Engine with Default Pawn Class attached to Player

One last thing before we start creating logic for the player, and that is the key bindings. Navigate to the Project Settings window (Edit > Project Settings…) and click on the Input tab.

Create two new Action Mappings.

  • Jump = space bar
  • Shoot = left mouse button

Unreal Engine Action mapping for FPS

Then we want to create two Axis Mappings.

  • Move_ForwardBack
    • W with a scale of 1.0
    • S with a scale of -1.0
  • Move_LeftRight
    • with a scale of -1.0
    • D with a scale of 1.0

Unreal Engine Axis Mapping for standard movement

Player Movement

Back in our Player blueprint, we can implement the movement, mouse look and jumping. Navigate to the Event Graph tab to begin.

First we have the movement. The two axis input event nodes will plug into an Add Movement Input node, which will move our player.

Player Movement Event Manager blueprinting in Unreal Engine

We can then press Play to test it out.

Next up, is the mouse look. We’ve got our camera and we want the ability to rotate it based on our mouse movement. We want this to be triggered every frame so start out with an Event Tick node.

This then plugs into an AddControllerYawInput and an AddControllerPitchInput. These nodes will rotate the camera along the Z and Y axis’. The amount will be based on the mouse movement multiplied by 1 and -1. -1 because the mouse Y value inverts the camera movement.

Event Manager to rotate camera with Player

If you press play, you’ll see that you can look left to right, but not up and down. To fix this, we need to tell the blueprint that we want to the camera to use the pawn’s control rotation. Select the Camera and enable Use Pawn Control Rotation.

Camera Event Graph overview

Now when you press play, you should be able to move and look around!

Jumping is relatively easy since we don’t need to manually calculate whether or not we’re standing on the ground. The CharacterMovement component has many build in nodes for us to do this easily.

Create the InputAction Jump node which is an event that gets triggered when we press the jump button. We’re then checking if we’re moving on ground (basically, are we standing on the ground). If so, jump!

Jumping logic for FPS player in Unreal Engine

We can change some of the jump properties. Select the CharacterMovement component.

  • Set the Jump Z Velocity to 600
  • Set the Air Control to 1.0

Event Graph overview for character movement

You can tweak the many settings on the component to fine tune your player controller.

Creating a Bullet Blueprint

Now it’s time to start on our shooting system. Let’s create a new blueprint with a parent type of Actor. Call it Bullet.

Bullet Blueprint created in Unreal Engine

Open it up in the blueprint editor. First, let’s create a new Sphere Collision component and drag it over the root node to make it the parent.

Sphere collision shape added to bullet in Unreal engine

In the Details panel…

  • Set the Sphere Radius to 10
  • Enable Simulation Generates Hit Events
  • Set the Collision Presets to Trigger

Now we have the ability to detect collisions when the collider enters another object.

Details for Bullet in Unreal Engine

Next, create a new component of type Static Mesh.

  • Set the Location to 0, 0, -10
  • Set the Scale to 0.2, 0.2, 0.2
  • Set the Static Mesh to Shape_Sphere
  • Set the Material to M_Metal_Gold
  • Set the Collision Presets to Trigger

Gold metallic material added to FPS bullet

Go over to the Event Graph tab and we can begin with out variables.

  • MoveSpeed (Float)
  • StartTime (Float)
  • Lifetime (Float)

Then click the Compile button. This will allow us to now set some default values.

  • MoveSpeed = 5000.0
  • Lifetime = 2.0

Components for bullet blueprint in Unreal Engine

We want our bullet to destroy itself after a set amount of time so that if we shoot the sky, it won’t go on forever. So our first set of nodes is going to set the start time variable at the start of the game.

Event Graph for Bullet blueprint in Unreal Engine

Over time, we want to move the bullet forward. So we’ll have the event tick node plug into an AddActorWorldOffset node. This adds a vector to our current location, moving us. The delta location is going to be our forward direction, multiplied by our move speed. You’ll see that we’re also multiplying by the event tick’s Delta Seconds. This makes it so the bullet will move at the same speed, no matter the frame rate.

AddActorWorldOffset node for Bullet shooting logic

Connect the flow to a Branch node. We’ll be checking each frame if the bullet has exceeded its lifetime. If so, we’ll destroy it.

DestroyActor node for Bullet blueprint

All the bullet needs now, is the ability to hit enemies. But we’ll work on that once enemies are implemented.

Shooting Bullets

Back in our Player blueprint, let’s implement shooting. First, we need to create an integer variable called Ammo. Compile, and set the default value to 20.

Ammo component added in Unreal Engine

To begin, let’s add in the InputAction Shoot node. This gets triggered when we press the left mouse button. Then we’re going to check if we’ve got any ammo. If so, the SpawnActor node will create a new object. Set the Class to Bullet.

Spawn logic for bullet in Unreal Engine

Next, we need to give the SpawnActor blueprint a spawn transform, owner and instigator. For the transform, we’ll make a new one. The location is going to be the muzzle and the rotation is going to be the muzzle’s rotation. For the owner and instigator, create a Get a Reference to Self node.

Spawn location logic for bullet in Unreal Engine

Finally, we can subtract 1 from our ammo count.

Ammo subtraction logic for FPS Unreal Engine project

We can now press play and see that the gun can shoot!

Creating the Enemy

Now it’s time to create the enemy and its AI. Create a new blueprint with the parent class of Character. Call it Enemy.

Enemy blueprint created for Unreal Engine FPS

Inside of the blueprint, create a new Skeletal Mesh component.

  • Set the Location to 0, 0, -88
  • Set the Rotation to 0, 0, -90
  • Set the Skeletal Mesh to mutant

Enemy mesh settings in Unreal Engine

Select the CapsuleComponent and set the Scale to 2. This will make the enemy bigger than the player.

Unreal Engine with capsule collision box added

Next, let’s go over to the Event Graph and create our variables.

  • Player (Player)
  • Attacking (Boolean)
  • Dead (Boolean)
  • AttackStartDistance (Float)
  • AttackHitDistance (Float)
  • Damage (Integer)
  • Health (Integer)

Hit the Compile button, then we can set some default values.

  • AttackStartDistance = 300.0
  • AttackHitDistance = 500.0
  • Health = 10

Unreal Engine components for Enemy blueprint

Let’s get started. First, we want to be using the Event Tick node which triggers every frame. If we’re not dead, then we can move towards the player. Fill in the properties as seen below.

Enemy Event Graph logic for moving towards the player

Back in the level editor, we need to generate a nav-mesh for the enemy to move along.

  1. In the Modes panel, search for the Nav Mesh Bounds Volume and drag it into the scene
  2. Set the X and Y size to 1000
  3. Set the size to 500

You can press P to toggle the nav-mesh visualizer on or off.

Unreal Engine with nav-mesh visualized for Enemy

You can also increase the size of the platform and nav mesh bound. Back in the enemy blueprint, let’s make it so when the game starts, we set our player variable.

Event Graph with Player variable set

Finally, let’s select the CharacterMovement component and change the Max Walk Speed to 300.

Character walking movement with max walk speed circled

Back in the level editor, let’s increase the size of the ground and nav mesh bounds.

Unreal Engine editor showing navmesh bounds

Let’s set some default values for the variables.

  • AttackStartDistance = 300.0
  • AttackHitDistance = 500.0
  • Damage = 1
  • Health = 10

Enemy Animations

Next, is to create the enemy animations and have those working. In the Blueprints folder, right click, select Animation > Animation Blueprint. Select the mutant for our skeleton, then click Ok. Call this blueprint: EnemyAnimator.

Animation blueprint for enemy

Double-clicking on it will open up the animation editor. On the top-left, we have a preview of our skeleton. At the bottom-left, we have a list of our 4 animations. You can open them up to see a preview in action.

Unreal Engine AnimGraph window

What we want to do now, is in the center graph, right click and create a new state machine. A state machine is basically a collection of logic to determine what animation we currently need to play.

New State Machine node for AnimGraph

You can then double-click on the state machine to go inside of it. This is where we’re going to connect our animations so that the animator can move between them in-game. Begin by dragging in each of the 4 animations.

Animation assets added to Enemy State Machine

Then we need to think… If we’re idle, what animations can we transition to? All of them, so on the idle state, click and drag on the border to each of the three others.

Animation state machine with various connections

We then need to do the same with the other states. Make the connections look like this:

State machine with various other connections for enemy animations

In order to apply logic, we need to create three new Boolean variables. Running, Attacking and Dead.

Variables available for Enemy in FPS Unreal project

You’ll see that next to the state transition lines is a circle button. Double-click on the one for idle -> run. This will open up a new screen where we can define the logic of moving along this transition. Drag in the Running variable and plug that into the Can Enter Transform node. So basically if running is true, then the transition will happen.

Running variable node added for Enemy

Back in the state machine open the run -> idle transition. Here, we want to do the opposite.

NOT node to project state machine logic in Unreal Engine

Go through and fill in the respective booleans for all of the transitions.

While we’re at it, let’s double click on the Mutant_Dying state, select the state and disable Loop Animation so it only plays once.

Enemy dying logic added to state machine

At the top of the state screen is an Event Graph tab. Click that to go to the graph where we can hook our three variables up to the enemy blueprint. First, we need to cast the owner to an enemy, then connect that to a Sequence node.

Event Graph for enemy with animation nodes

To set the running variable, we’re going to be checking the enemy’s velocity.

Logic to check enemy velocity

For attacking, we just want to get the enemy’s attacking variable.

Logic to check if enemy is attacking

The same for dead.

Logic to check if enemy is dead

Back in the Enemy blueprint, select the SkeletalMesh component and set the Anim Class to be our new EnemyAnimator.

Enemy with Anim Class added in Unreal Engine

Press play and see the results!

Attacking the Player

In the Enemy blueprint, let’s continue the flow from the AIMoveTo component’s On Success output. We basically want to check if we’re not current attacking. If so, then set attacking to true, wait 2.6 seconds (attack animation duration), then set attacking to false.

Attack logic for enemy to attack FPS player

If you press play, you should see that the enemy runs after you, then attacks. For it to do damage though, we’ll first need to go over to the Player blueprint and create two new variables. Compile and set both default values to 10.

Unreal Engine components for Health

Next, create a new function called TakeDamage.

Logic to take damage for FPS Unreal Engine project

Back in the Enemy blueprint, create a new function called AttackPlayer.

Enemy logic for attacking the player in FPS

To trigger this function, we need to go to the enemy animation editor and double-click on the swiping animation in the bottom-left. Here, we want to drag the playhead (bottom of the screen) to the frame where we want to attack the player. Right click and select Add Notify… > New Notify…

Call it Hit.

Hit trigger added to enemy attack

Then back in the animator event graph, we can create the AnimNotify_Hit event. This gets triggered by that notify.

AnimNotify Hit node added to Event Graph

Now you can press play and see that after 10 hits, the level will reset.

Shooting the Enemy

Finally, we can implement the ability for the player to kill the enemy. In the Enemy blueprint, create a new function called TakeDamage. Give it an input of DamageToTake as an integer.

Inputs Details circled in Unreal Engine Event Graph

Then in the Bullet blueprint, we can check for a collider overlap and deal damage to the enemy.

Bullet blueprint checking for collider in Unreal Engine

If you press play, you should be able to shoot the enemy and after a few bullets, they should die.

Conclusion

And there we are!

Thank you for following along with the tutorial! You should now have a functional first-person shooter with a player controller and enemy AI – complete with animations and dynamic state machine!  Not only will your players be able to dash about the stage jumping and shooting at their leisure, but the health mechanics create a challenge to stay alive.  You’ve accomplished this and more with just Unreal Engine’s blueprinting system as well, learning how to control nodes to provide a variety of functionality.

From here, you can expand the game or create an entirely new one.  Perhaps you want to add more enemies, or create an exciting 3D level where enemies might be just around that shadow-y corner!  The sky is the limit, but with these foundations you have all you need to get started with robust FPS creation in Unreal Engine.

We wish you luck with your future games!

Unreal Engine FPS game project

]]>
How to Create a ROBLOX Action Game: Arena Combat https://gamedevacademy.org/roblox-arena-combat-tutorial/ Wed, 30 Jun 2021 01:00:56 +0000 https://gamedevacademy.org/?p=14019 Read more]]> In this tutorial, we’ll be creating an arena combat game in Roblox – featuring repeating rounds of combat that allows players to increase their score.

Not only will you learn some nifty tricks to programming with Lua by a professional developer, but with Roblox game making’s soaring popularity, you can this multiplayer game available to millions of players instantly!

Let’s start learning and building our Roblox game project!

complete roblox combat arena game

Project Files

You can download the complete .rblx project file here.

Do note that this tutorial will not go over the basics of Roblox Studio. If this is your first time developing with Roblox, you can learn the basics here.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

Creating the Lobby

Let’s start by creating a brand new project – using the Baseplate template.

new roblox studio project

The first thing we’re going to do is set up our lobby area. This is where players will spawn and wait for the game to begin. In the Explorer, select the Baseplate part.

  • Down in the Properties window, let’s change the Scale to 100, 6, 100.
  • I also went ahead and changed the Color to deep orange.

setting up the baseplate in Roblox Studio

Next, we can setup the spawn location.

  • Delete the Decal child part.
  • Select the SpawnLocation and set the Transparency to 1.
  • Disable CanCollide and CanTouch.

fixing the spawn location in Roblox Studio arena combat project

We’ve got the baseplate and spawn location setup. Now we need to make it so that players can’t jump off the platform. To do this, we’ll be adding in invisible walls around the baseplate.

  1. Create a new Block part.
  2. Scale and position it along one side of the baseplate.
  3. Rename it to InvisibleWall.

creating an invisible wall in Roblox Studio arena level

Then we can set the Transparency to 1 to make the wall invisible.

setting the wall transparency to 1 in Roblox Studio

Duplicate the wall three times and move/rotate them so they surround the baseplate like so…

adding in the final invisible walls to Roblox arena combat game project

Now you can play the game (F5) and make sure that you cannot jump off the baseplate.

To make our workspace a bit cleaner, let’s create a folder called Lobby and store all of our lobby parts in it.

creating the lobby folder in Roblox Studio Explorer

You may also notice that the sky looks a bit weird, this is due to us using the baseplate template. To fix this, open up the Lighting service and delete the Sky. Then re-add it.

fixing the sky part in Roblox Studio

Creating the Arena

Now that we have our lobby, let’s create the arena that the players will be fighting in. This is going to be a separate area from the lobby. Let’s start by creating a new block part for our floor.

  • Rename it to Floor.
  • Set the Brick Color to gold.
  • Set the Material to sand.
  • Set the Size to 200, 16, 200.
  • Make sure to also enable Anchored so that the platform doesn’t fall.

arena floor creation in Roblox Studio

Next, we’ll need to create the walls for our arena. This can be whatever you wish. For mine, I went for a colosseum style. Using the modeling tools (union and negate).

creating the arena walls in Roblox studio

Then finally, we can add in obstacles and platforms for the players to move around.

arena obstacles and platforms added in Roblox Studio editor

Just like with our lobby, let’s also put the arena into its own folder.

arena folder in Roblox Studio Explorer

Spawn Points

For our arena, we need to create spawn points for players to spawn at. Create a new brick part.

  • Set the Transparency to 1.
  • Set the Size to 5, 1, 5.

spawn point added in Roblox Studio editor and Explorer

Now we can duplicate and put these spawn points all around the arena. Then create a folder called SpawnPoints in the Arena folder to store them.

spawn points folder for Roblox Studio arena game project

Game Loop

Now that we’ve got all of the environments and spawns set up, let’s get the game loop working. It will act like this:

  1. Players start in the Lobby
  2. After 5 or so seconds, all players will be teleported to the Arena.
  3. After 30 seconds, all players will be teleported back to the Lobby.
  4. Repeat.

To get this working, we need to create two objects which will contain the game’s state. A BoolValue and a StringValue.

  • A bool value can hold a true or false value.
    • We’ll be using this to know if the game’s currently active (players are in arena).
  • A string value can hold a string of text.
    • We’ll be using this to update the current time remaining for all players.

In the Explorer, go over to the ReplicatedStorage service and create those two things (rename them appropriately). ReplicatedStorage is where we can put objects that are stored on the server.

Roblox Studio Explore with the Replicated Storage section circled

Next, in the ServerScriptService service, create a new script called GameManager.

Roblox Studio with the GameManger script selected

Let’s start with our variables.

local GameLength = 20
local LobbyWaitLength = 5
local PlayersRequiredToBegin = 1

local LobbySpawn = game.Workspace.Lobby.SpawnLocation
local ArenaSpawnPoints = game.Workspace.Arena.SpawnPoints:GetChildren()

local GameActive = game.ReplicatedStorage.GameActive
local Status = game.ReplicatedStorage.Status

Then we need to create the LobbyTimer function. This runs when all the players are in the lobby, waiting for a new game to start. Here’s what it does…

  1. As long as the GameActive bool is false:
    1. Wait for the required players to join the game.
    2. When that number is met, countdown.
    3. When the countdown is complete, set the GameActive value to true.
local function LobbyTimer ()
	while GameActive.Value == false do
		local players = game.Players:GetChildren()
		local playerCount = #players


		if playerCount < PlayersRequiredToBegin then
			Status.Value = "Waiting for players"
		else
			for i = LobbyWaitLength, 1, -1 do
				Status.Value = "Starting game in... ".. i
				wait(1)
			end
			GameActive.Value = true
			return
		end

		wait(1)
	end
end

We then also have the GameTimer function. This runs when the players are in the arena, giving them a set length of time to play the game, before changing the GameActive value back to false.

local function GameTimer ()
	for i = GameLength, 1, -1 do
		Status.Value = i .." seconds remaining!"
		wait(1)
	end
	GameActive.Value = false
end

Now, this is just counting down, we’re not teleporting the player or anything yet. This is done when we change the GameActive value. We can create this event which gets triggered when GameActive changes to true or false.

GameActive.Changed:Connect(function()




end)

If the value is true, then teleport all players into the arena and give them max health.

GameActive.Changed:Connect(function()
	if GameActive.Value == true then
		for i, player in pairs(game.Players:GetChildren()) do
			local character = player.Character
			character.HumanoidRootPart.CFrame = ArenaSpawnPoints[i].CFrame
			character.Humanoid.Health = character.Humanoid.MaxHealth
		end
		GameTimer()
	else
end)

Otherwise, if it’s false, then we can teleport all players back to the lobby.

GameActive.Changed:Connect(function()
	if GameActive.Value == true then
		for i, player in pairs(game.Players:GetChildren()) do
			local character = player.Character
			character.HumanoidRootPart.CFrame = ArenaSpawnPoints[i].CFrame
			character.Humanoid.Health = character.Humanoid.MaxHealth
		end
		GameTimer()
	else
		for i, player in pairs(game.Players:GetChildren()) do
			local character = player.Character
			character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
		end
		LobbyTimer()
	end
end)

Finally, at the bottom of the script – we can call the initial LobbyTimer function.

LobbyTimer()

Now you can test it out!

UI

In order to see how much time we have left, let’s create some text on-screen.

In the StarterGui service, create a new ScreenGui object and as a child of that, create a TextLabel.

setting up the ui with a TextLabel in Roblox Studio

In our game view, drag the text label to the top-center of the screen.

  • Rename it to StatusText
  • Set the Text to Starting game in… 5

creating the text label and centering it in Roblox Studio

  • Set the BackgroundTransparency to 1.
  • Set the AnchorPoint to 0.5, 1.
  • Set the TextSize to 30.

Changing the text label in Roblox Studio arena project

As a child of ScreenGui, create a new LocalScript. A local script is the same as a script but it only runs on the client – not the server.

local script selected in Roblox Studio arena combat game

All this code will do, is update the text to display the status when the text changes.

local Status = game.ReplicatedStorage.Status
local TimerText = script.Parent.StatusText

Status.Changed:Connect(function()
	TimerText.Text = Status.Value
end)

Creating the Weapon

Now let’s create the weapon which our players will be using. For the model, we can use the Toolbox window to find one which looks good.

importing the sword in Roblox Studio

First, open up the sword’s children object and DELETE:

  • ThumbnailCamera
  • MouseIcon

We won’t be needing those. You can then rename the sword to Sword.

Next, drag the sword into ReplicatedStorage as it will be held on the server and given to players when needed by the GameManager script.

creating the sword script in Roblox Studio Explorer

After this, open up the SwordScript and delete all the code there – we’ll be creating our own from scratch. First, the variables.

local Tool = script.Parent
local CanDamage = false
local Damage = 25
local Target

Then we can create the OnTouched function. This gets called when the sword hits another part. We need to first make sure that it’s a player and if so, damage them.

local function OnTouched (otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

	if not humanoid then
		return
	end

	if humanoid.Parent ~= Tool.Parent and CanDamage and Target ~= humanoid then
		Target = humanoid

		humanoid:TakeDamage(25)
	else
		return
	end

	CanDamage = false
end

The Attack function gets called when we click our mouse button. This will play a swing animation.

local function Attack ()
	Target = nil

	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Slash"
	anim.Parent = Tool
	CanDamage = true
	wait(0.5)
	CanDamage = false
end

Then finally, we need to hook these functions up to their respective events.

Tool.Activated:Connect(Attack)
Tool.Handle.Touched:Connect(OnTouched)

Here’s the final script.

local Tool = script.Parent
local CanDamage = false
local Damage = 25
local Target

local function OnTouched (otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

	if not humanoid then
		return
	end

	if humanoid.Parent ~= Tool.Parent and CanDamage and Target ~= humanoid then
		Target = humanoid

		humanoid:TakeDamage(25)
	else
		return
	end

	CanDamage = false
end

local function Attack ()
	Target = nil

	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Slash"
	anim.Parent = Tool
	CanDamage = true
	wait(0.5)
	CanDamage = false
end

Tool.Activated:Connect(Attack)
Tool.Handle.Touched:Connect(OnTouched)

Equipping the Weapon

We’ve got our weapon, now we need to give it to the players when they spawn in the arena and remove it when back in the lobby.

Let’s go over to the GameManager script and create a variable referencing the weapon.

local Weapon = game.ReplicatedStorage.Sword

Then when the game active value is true, we want to add the weapon to each player’s backpack and equip it.

local tool = Weapon:Clone()
tool.Parent = player.Backpack
character.Humanoid:EquipTool(tool)

giving weapon code as seen in code editor

Then when game active is false, remove the weapon.

for _, obj in pairs(character:GetChildren()) do
    if obj:IsA("Tool") then
        obj:Destroy()
    end
end

code snippet for for loop in code editor

Here’s the GameActive.Changed event with the final code:

GameActive.Changed:Connect(function()
	-- teleport all players into the ARENA and GIVE them a weapon
	if GameActive.Value == true then
		for i, player in pairs(game.Players:GetChildren()) do
			local character = player.Character
			character.HumanoidRootPart.CFrame = ArenaSpawnPoints[i].CFrame
			local tool = Weapon:Clone()
			tool.Parent = player.Backpack
			character.Humanoid:EquipTool(tool)
			
			character.Humanoid.Health = character.Humanoid.MaxHealth
		end
		GameTimer()
		-- teleport all players into the LOBBY and REMOVE their weapon
	else
		for i, player in pairs(game.Players:GetChildren()) do
			local character = player.Character
			character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
			
			for _, obj in pairs(character:GetChildren()) do
				if obj:IsA("Tool") then
					obj:Destroy()
				end
			end
		end
		LobbyTimer()
	end
end)

Leaderstats

We’ve got most of the game setup and working. But there’s no score right now. So how do we do that?

In the ServerScriptService, create a new script called Leaderboard. This is where we’re going to create and manage player kills.

leaderboard script in Roblox Studio explorer

First, let’s get a list of all the players.

local Players = game.Players

Then we can create the SetupLeaderboard function. This will be called when a new player joins the game.

local function SetupLeaderboard (player)

end)

Inside of this function, let’s create our leaderstats folder. It’s important that the names are the exact same as the code below, as the game requires specific naming.

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

Now with our leaderstats, let’s create a new int value to store our kills.

local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = leaderstats

Then (still inside of the function), let’s run some code when the player’s character has been added.

player.CharacterAdded:Connect(function(character)
	local humanoid = character:WaitForChild("Humanoid")
	local objectValue = Instance.new("ObjectValue")
	objectValue.Name = "Killer"
	objectValue.Parent = humanoid

	humanoid.Died:Connect(function()
		local killer = humanoid:WaitForChild("Killer")

		if killer then
			game.Players:GetPlayerFromCharacter(character).leaderstats.Kills.Value += 1
			killer = nil
		end
	end)
end)

Finally, at the bottom of the script, let’s call the SetupLeaderboard function every time a new player joins the game.

Players.PlayerAdded:Connect(SetupLeaderboard)

Here’s the final script.

local Players = game.Players

local function SetupLeaderboard (player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local kills = Instance.new("IntValue")
	kills.Name = "Kills"
	kills.Parent = leaderstats

	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		local objectValue = Instance.new("ObjectValue")
		objectValue.Name = "Killer"
		objectValue.Parent = humanoid

		humanoid.Died:Connect(function()
			local killer = humanoid:WaitForChild("Killer")

			if killer then
				game.Players:GetPlayerFromCharacter(character).leaderstats.Kills.Value += 1
				killer = nil
			end
		end)
	end)
end

Players.PlayerAdded:Connect(SetupLeaderboard)

Connecting the Weapon to the Leaderboard

Now that we have our leaderboard, let’s go back to our weapon script and navigate over to the onTouched function. Just before we take damage (the line above humanoid:TakeDamage(25)), we want to set that player’s Killer value to be us – the attacker.

humanoid:FindFirstChild("Killer").Value = Tool.Parent

Here’s what the full function looks like:

local function OnTouched (otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

	if not humanoid then
		return
	end

	if humanoid.Parent ~= Tool.Parent and CanDamage and Target ~= humanoid then
		Target = humanoid

		humanoid:FindFirstChild("Killer").Value = Tool.Parent
		humanoid:TakeDamage(25)
	else
		return
	end

	CanDamage = false
end

Testing on Multiple Clients

Now we can test our game! To test a multiplayer game, you need multiple clients. Roblox Studio has that feature build in. Over in the Test tab, you can select the number of clients, then click Start.

multiple clients testing option in Roblox Studio

Once done, just click on the Cleanup button to close the clients and server.

Conclusion

There we go! We now have a fully functional multiplayer arena combat game in Roblox. Over the course of this tutorial, we’ve learned a lot! We set up a level, learned how to manage our spawn points, created a UI, added weapon combat, and more! We even learned how Roblox game making makes it super easy to make our games multiplayer without a lot of complicated coding.

From here, you can expand in a number of ways. If you enjoyed this project, you can try adding in new features such as different weapons, powerups, etc – all common features for battle royale types of games. Or, since we’ve learned a lot about Roblox Studio’s features and Lua, you can use your new knowledge to create a different game all together – whether that be some sort of race car game, pet game, or something else entirely.

Thank you very much for following along, and I wish you the best of luck with your future Roblox games.

]]>
Free Course – A Guide to 3rd Person Players in Unity https://gamedevacademy.org/3rd-person-player-unity-tutorial/ Wed, 30 Dec 2020 01:00:03 +0000 https://coding.degree/?p=800 Read more]]>

Start creating third-person action RPGs and more by first learning how to set up player movement with orbital camera! You can also extend the material covered here by checking out the full course below!

Action RPG Development for Beginners

About

Created by Daniel Buckley, this mini-course will show you step-by-step how to set up a third-person character controller using simple primitive objects in Unity. You’ll learn key skills including how to prepare the player in Unity, how to add standard movements like walking and jumping, and how to implement features for the camera to orbit around the player. Regardless of what sort of game you want to build, these player scripts will provide a strong foundation as you expand your skills and build your dream game projects!

]]>
Make Games without Coding – Free Unreal Engine Ebook https://gamedevacademy.org/make-games-without-coding-free-unreal-engine-ebook/ Mon, 28 Dec 2020 01:22:48 +0000 https://gamedevacademy.org/?p=2044 Read more]]> We are excited to announce our latest eBook: Unreal Engine Game Development for Beginners

Authored by Unreal Engine expert Daniel Buckley, this eBook explores all there is to know about getting started with Unreal Engine development. You’ll learn not only how to work with the foundations of the engine itself, but also develop several projects from scratch including an FPS game, an action RPG, a road-crossing game, a platfromer, and a puzzle-like game! In addition, you’ll do all this while using the Blueprints Visual Scripting system – meaning no prior coding knowledge is required or needed to create your game projects!

Whether you’ve always wanted to learn Unreal Engine or want to start putting knowledge into practice, this eBook will help you gain the in-demand skills necessary to start building your dream game projects!

Download the eBook here

]]>
Free Course – Create an FPS Controller in Unreal Engine https://gamedevacademy.org/unreal-engine-fps-controller-tutorial/ Mon, 26 Oct 2020 01:00:53 +0000 https://coding.degree/?p=438 Read more]]>

Start learning how to make an FPS game in the popular Unreal Engine using the Blueprints Visual Scripting system – a fantastic way for beginners to “code”.  You can also extend the material covered here by checking out the full course below!

Develop a First-Person Shooter in Unreal Engine

About

In this free tutorial, instructor Daniel Buckley will walk you through the beginning steps of creating a first-person shooter game in the popular Unreal Engine. Using visual scripting code blocks, you’ll learn how to set up both the player character and camera for a first-person viewpoint, one of the most crucial aspects of any first-person game. With the skills provided, you will not only be able to create portfolio-worthy projects, but also learn techniques that you can expand for whatever FPS type of game you wish to create!

]]>