Showing posts with label game design. Show all posts
Showing posts with label game design. Show all posts

Tuesday, March 5, 2019

Patrolling Enemy Tutorial



One of the most-requested features I get asked about in the Game Design classes I teach is how to make a patrolling enemy that will "spot" the player. I've been making a lot of video tutorials lately, but for this one I've decided to make a text tutorial. So here it is, how to set up a basic patrolling enemy that will "spot" the player.


Patrolling Enemy
Download Enemy Character and Animations from Mixamo
  1. Log in or sign up
  2. From the Characters tab, select a character you like
  3. From the Animations tab, select a walk cycle
  4. Check the box for In Place
  5. Download as FBX for Unity
  6. Download a second time for Collada, which gives a .zip folder with the texture files
  7. Find a second animation, such as an Attack, and download as FBX for Unity
  8. Import the FBX and the texture files to Unity
Setup and Bake NavMesh in Unity
  1. Create a Ground Plane in a new empty scene
  2. Open the navigation panel: Window > AI > Navigation
  3. Select the Ground Plane and mark it as Navigation Static and Walkable
  4. Create some obstacles for the enemy to walk around, it’s a good idea to change the color of the ground and obstacle so you can see what you’re doing
  5. Marke the obstacles as Navigation Static and Not Walkable
  6. Select the Bake tab and choose Bake
Create NavMeshAgent and Player Character Controller
  1. Create a Character Controller for the player, or download the Unity Standard Assets FPS controller and place it in your scene (if using the FPS controller, be sure it is above the ground)
  2. Create a 3D Capsule object in your scene and give it a NavMeshAgent Component
  3. Create a new C# Script called Enemy and attach it to the Capsule
  4. Open the script and create a Public Array of GameObjects
  5. Back in the Unity scene, select the Capsule and set the public array size to 3
  6. Create 3 Empty GameObjects and place them around the scene (these will be the waypoints for the enemy to walk to)
  7. Drag each of the waypoints into one of the GameObject slots on the Capsule
  8. Back in the Enemy script, add using UnityEngine.AI to the top of the script, create a private NavMeshAgent and in the Start function give it a reference to the NavMeshAgent component
  9. Create a private int to keep track of the current waypoint, then in the Start and Update functions specify the desired waypoint for the NavMeshAgent.destination
  10. Save and test and you will see the enemy walk between each of the waypoints until it reaches the end of the patrol path...update the script so the patrol loops by resetting currentWaypoint to 0 when you reach the end
  11. Test again to ensure the enemy loops on the patrol path
Link Character Model and Animation to NavMeshAgent
  1. Drag the enemy character model onto the Capsule to make it a child and turn off the Mesh Renderer on the Capsule
  2. Select the enemy character model in the scene and drag the Walking animation onto the Animator component

    Note that it creates an Animator Controller in your project folder when you do this
  3. Apply the textures to the character Geo
  4. Select the walking animation and choose Edit
  5. Check the box for Loop Time and Apply
  6. Test again to see the character walking along the patrol path. While testing, check to ensure the character’s feet are making contact with the ground
Script Enemy Vision and Attack Trigger
  1. Attach a Box Collider component to the enemy Capsule and mark it as Is Trigger and position and scale it to represent the view area of the enemy
  2. Add an OnTriggerStay function to your Enemy script to check for the Player character
  3. Be sure to tag the player as Player
  4. You may want to expand your play space to test this new functionality, be sure to rebake the NavMesh if you do
  5. Open the Animator wind from Window > Animation > Animator
  6. Select the animated enemy character and drag the Attack animation into the Animator
  7. On the Parameters tab make a new Trigger called ‘Attack’
  8. Right click on the Walking animation and make a transition to the Attack animation
  9. Make a corresponding transition from the Attack to the Walking animation
  10. Select the transition to the Attack and add a condition for the Attack trigger you made before and uncheck the box for Has Exit Time
  11. If the enemy is within range of the player, set the target destination to the enemy’s current position and trigger the attack animation, otherwise use the player’s position as the destination
Summary
After completing these steps, you should have a patrolling character that will interrupt it’s patrol to follow the player if the player gets in her view range, and if the enemy gets close enough to the player while following she will attack. If the player gets out of the view range of the enemy she will return to her patrol.

Thanks for reading, and if you've found this tutorial helpful I hope you will subscribe here and on my Youtube channel: www.youtube.com/c/AstireGames

Friday, October 5, 2018

The Making of Cosmos Arena



Cosmos Arena is a local multiplayer party game for up to 4 players. Right now it is PC only but we hope to make an XBox port as well.



I'd like to share with you the story of how Cosmos Arena came to be.

Getting Started

My team started working on this project in 2016 when I was still working a full time job in AAA. I launched my studio Astire Games and brought on some contractors, most of whom were also working day jobs, so we were moonlighting to get to the first prototype.

First Prototype

In this prototype we started on the core mechanics - character movement and traps

At some point I realized that AAA work was not satisfying my drive as a developer, and working nights and weekends on Cosmos Arena wasn't enough for me. On top of working AAA and moonlighting, I was also teaching Game Design as an adjunct faculty.

Leaving a comfortable day job for a side project is a risky move, and I don't think I would have done it if not for the teaching gig. I was pretty confident I could live on my teaching income for at least a few months, so I decided to take the leap and I left AAA to go indie.


Funding

Anyone who has tried to get a project up off the ground knows that it takes money. Even if you are the only one working on the project, you at least need enough for yourself to live on, but if you plan on having other people work on the project then you need a starting fund.

I was teaching 8 hours a week, and I figured if I really stretched I could live on that income. But I also wanted to have other people working on this project...There wasn't a particular skillset I was looking for since it was all prototyping at that point, but working alone can be lonely and it can be hard to stay motivated. So I found some friends who were looking for a side project who were willing to work on the cheap, and I dug into my savings from my time working in AAA.

In a lot of ways I got really lucky - I have some very talented and supportive friends with a wide range of skills, and it wasn't long at all before we had a second prototype with character animations, obstacles, sound effects, and a start screen.

Second Prototype


Contract Work

Self-funding Cosmos Arena had a limited lifespan, which I knew going in. I had hoped to get the prototype to a point where I could start soliciting outside funding.

This is where my luck started to run out...I had basically no idea how to get funding for a project. I tried looking for potential publishers, but the prototype was just not ready to meet those expectations. On top of that, I hadn't been able to find an environment artist, and the character artist and one of the programmers were leaving for new full time jobs.

I managed to rough out the scene with some placeholder art from the Unity Asset Store, but it still needed a lot of work and I was running out of money and people.

First Art Style


Around this time I decided I either needed to get a job, or find some contract work for my team. As it happened, a contract project kind of fell into my lap. I had a programmer and a sound designer still on my team, and I was contacted by a couple who had a vision for a children's app and a budget for development. They already had some art made for it, so I jumped at the opportunity.

Contract work was great, it allowed me to keep my team together and add some new folks, and it added to the company bank account. But it was time-consuming, and it pretty much put Cosmos Arena on the back burner for several months.

Showcasing

At a couple of different times, we had an opportunity to showcase Cosmos Arena at local events. These opportunities were fantastic for getting me motivated to dive back into the project - usually there would be about 2 weeks to a month where I knew the game would be showcased and I wanted it to have something new to show, so there would be a hard push to get in new content and new features.

Showcase Build


Our showcase opportunities included the Intel Buzz Workshop at the Austin Games Conference, the Intel Indie Lounge at the Game Developers Conference, the Austin Game Dev booth at SXSW, and the IGDA booth at Dreamhack.

Second Showcase Build


Interns

Due to the sporadic nature of development on this project, all of the original team moved on to other things at various points during this timeline. Still on a tight budget, I decided to leverage my position teaching to find rising new talent looking for opportunities.

Initially I started taking interns at my company and letting them work on their own projects, which I then helped them publish. Finally I decided I had found the right interns for Cosmos Arena, so I offered them paid contract internships to spend the summer building levels.

Bringing on interns also coincided with finally having an artist to set the art direction of the project.

New Art Style and Levels


Art Direction and Iteration

There has been a lot of iteration and changes to the art style over the past two years, but honestly most of that iteration happened in the last 3 months. Here is a glimpse of some of that iteration...

















Game Mechanics and Iteration

Not only did the art style change dramatically over time, also our core mechanics and design have changed. We've added new win conditions for different levels, replaced a health/damage system with a shield and one-hit-kill, we added a ghost mode when a player dies so they can take revenge on their killer, and we've incorporated building and planting to offset the killing and destroying.

Development


Alpha Release

We just hit our Alpha milestone and decided to make the game available for free for a limited time while we work through some bugs and collect feedback. If you've enjoyed learning about our development process, we would love for you to try the game and give us your feedback :)


Thanks for reading and thanks for playing!