
Welcome to Learn Game Artificial Intelligence with Unity Visual Scripting! This video is an overview of what you'll learn in the course.
H3D has a bustling online student community. Here's how to get involved.
Important Reading on Common Issues students have and how to ask for help.
We'll start by covering core visual scripting concepts. While the section is for beginners, we move along at a steady pace. In this video we'll go over project setup, importing packages, and how the project folders of the course are organized.
Here we rotate the sun and use variables to change the length of a day.
How do we determine day and night? We'll create a graph that looks at the rotation of the sun and sets a scene variable for other graphs to use.
Our scene is mostly empty; let's add a couple things to the world that will later respond to Custom Events.
Here we'll start creating an event system based on whether it is day or night. We'll first get our event handler to turn on fireflies at night.
There are a lot of streetlights to turn on in JimCity! We can use for loops and parent-child relationships to turn on a bunch of them at once, using only one event from our event system.
We want to add a bunch of things to happen at day or night, so in this lecture we'll add lists to our event handler graph. The streetlights are finally working! Lastly, we'll add a rooster to liven up the morning.
We definitely need more glowy things at night. Here we'll use timers on Shader Graph parameters to fade in a night sky.
As a capstone to the Day-Night Cycle section, we'll create an in-game clock and sync our sun to it. It'll take a while to set this up, but the math is all pretty simple. You're welcome to skip the clock if you wish to move on. In that case, bookmark these lectures as a stand-alone, broadly useful mini-project that's easy to come back to.
Pit stop! Let's take a look at debugging to check values and events in our scripts. This way we can isolate problems and fix them.
We'll finish our clock by converting the 24 hour clock to 12 hours and syncing the sun up to it.
This addendum lecture is to help you get started with creating an hourly event system based on the in-game clock. We don't have characters moving yet, but I wanted to give you some ideas for how to incorporate the in-game clock with content you'll learn in the next sections of the course.
Navigation Meshes are a tool to create characters that move around intelligently in our world. We'll start by getting an "agent" to go to a destination.
How can our clicks reach places in the world? We'll use raycasts to start building a simple player controller to move around our town sandbox.
We'll take a quick dive into Unity's Cinemachine suite to set up a simple follow-player camera.
It's easy to get animations under control, the tricky part is refining them. We'll do a little of both.
It wouldn't be a day at the pond without some friendly ducks. When the player enters a trigger, the agents will follow them.
After the player leaves the trigger, the ducks will go back to a random destination near their home area.
Subgraphs are graphs inside graphs. Clean up your VS spaghetti and plop them anywhere you want to reuse graphs.
In this video we'll set up waypoints and program our agents to wander randomly to each of them.
Even though we are using the same graph for the NPCs, we can randomize parameters so that they each move differently.
Cars present a situation where the wheels alone are not enough to carve out the nav mesh. We'll use Nav Mesh Obstacles to prevent NPCs from walking through areas where they shouldn't go.
How do you move things in Unity? We'll use Set Position with the logic you've already learned to create cars that travel back and forth.
Custom Events can also send along data, called arguments. This way we can tell each car on the road exactly when to go.
Here we'll use instantiation to spawn ghosts into the world with a puff of smoke. This way we have something spooky for the NPCs to run away from.
After adding some more default behavior, we'll create a script for our agents to see anything on the "Enemy" layer.
It's often unnecessary for something to happen every frame. This is especially important in visual scripting which, for now, is slower than C#. We can improve performance by reducing Update calls.
Now that the agents can see ghosts, we'll get them to run away. We'll find a Nav Mesh Path away from the ghost and ensure that it is a valid waypoint.
In this section we'll switch to a sci-fi action prototype scene to use UVS's State Machines. The resource package will import with a few errors that are easily fixed. I'll also highlight the assets we're using.
Our first state machine will be an automatic door that opens with the player entering a trigger.
DOTween is an excellent free asset for giving us control over changing values over time on Unity components.
We have a turret prefab that has health, effects, bullets, and a firing event. We'll add a state machine and make it so the turret fires when the player hits a trigger.
Now things get interesting! We'll rotate our turret a variety of ways while using Cooldown and Timers to tune the timing of the firing.
Thus far the turret's aim has been automatic and unaware of the player. Let's make it so that the turret fires at the player.
Taking things up a notch, we'll make our turret smarter and much more challenging to go up against. We'll determine the player's speed, and I'll give you a custom predictive aim node for the rest.
Here we'll set up a classic enemy AI state machine with patrol, chase, and attack states.
Starting with the Perception state, we'll create the logic for seeing the player and determining whether they are within attack range.
We'll make the robot have a predictable patrol route (with some random pauses) so the player can study the enemy and plan their approach to tackling or avoiding threats in the level.
Here we'll complete the robot's basic behavior. We'll use DOTween's "DOColor" to change the sword's color in each state. We'll also use Animation Events to control the enemy's attack rotations, giving the player a chance to dodge and attack or run away.
Here we'll walk through the health graph and set up the turret's death event so that it stops shooting at the player.
Congratulations, you made it to the end! We'll have some extra content for you in the next section.
Strap yourself in: Programming Artificial Intelligence is about to click!
My name is Jim, and I'll be your instructor. Creating this course has been a dream of mine ever since I made the official tutorials for Bolt on Unity's Learn Site. In collaboration with Holistic3D, I took Penny's quintessential C# tutorial series The Beginner's Guide to Artificial Intelligence and adapted it to *drumroll*... Unity Visual Scripting!
In this course, you're getting the best of both worlds:
Learning content from Penny, a renowned expert on AI and computer science..
...remixed, riffed on, and presented by me, a creative artist and designer. I've helped thousands learn visual scripting from the early years to today. Through an open-ended, practice-based approach you will follow along as each step is revealed for you to build two game worlds created with Unity 2021.3.9
Here's the list of what we'll make together:
For total beginners, we start with a Day/Night Cycle to bring sunsets and sunrises to your game worlds.
We'll use Custom Events to make fireflies appear and turn streetlights on in the night.
Want something more advanced? We'll make an in-game clock and sync it with the sun.
Set up a Click-To-Move Player Controller using Cinemachine and Unity's Nav Mesh system.
Bring to life wildlife in the form of ducks and rats that respond to the world around them.
Populate a city with crowds of NPCs who wander around, avoid cars, and run away from ghosts
Master rotations and timing with a laser gun turret
We'll use predictive aiming to make challenging enemies for the player to face
Finesse Enemy AI with improved algorithms for Patrol, Chase and Attack strategies
Extra Content! at the end, based on your requests and questions.
By the end of this course you will have:
A full understanding of UVS and Unity's API - the foundation to make what you imagine
An in-game time system - make your game worlds dynamic from the start
Familiarity with 3D game mathematics - you'll be comfortable and confident moving and rotating objects in Unity
Learned Unity's Nav Mesh System - add lifelike characters and creatures to your game worlds
State machines as an essential part of your game dev toolset - create AI behaviors that respond to the environment and the player's actions
Two sandbox projects, a city and sci-fi action prototype - keep libraries of graphs ready to drop into any of your games
Joined the friendly and active UVS and Holistic3D communities - share your progress, get unstuck, and connect with other UVS creators like you
We're so excited to share the course with you and can't wait to see how you run with it,
- Jim @HomeMech