Quantcast
Channel: Envato Tuts+ Game Development
Viewing all 728 articles
Browse latest View live

Unity Solution for Hitting Moving Targets

$
0
0
Final product image
What You'll Be Creating

While developing games which involve an action element, we often need to figure out a way to collide with a moving target. Such scenarios can be typically called a 'hitting a moving target' problem. This is particularly prominent in tower defense games or missile command like games. We may need to create an AI or algorithm which could figure out the enemy's motion and fire at it. 

Let's see how we can solve this particular problem, this time in Unity.

1. The Missile Command Game

For this particular tutorial, we will consider a missile command game. In the game we have a turret on the ground which fires missiles at an incoming asteroid. We should not allow the asteroid to hit the ground. 

The game play is tap-based, where we need to tap to aim the turret. With human assistance, the game mechanics are pretty straightforward as the turret just needs to aim and fire. But imagine if the turret needs to automatically fire at incoming asteroids. 

The Challenges for Auto-Firing AI

The turret needs to find out how many asteroids are approaching the ground. Once it has a set of all approaching asteroids, it would then need to do a threat analysis to determine which one to target. A slow-moving asteroid is a lesser threat than a fast-moving one. Also, an asteroid which is closer to the ground is an imminent threat as well. 

These problems can be solved by comparing the speed and position of the incoming asteroids. Once we have determined which one to target, we reach the most complicated problem. When should the turret fire? At which angle should it fire? When should the missile set to explode after firing? The third question becomes relevant because the missile explosion can also destroy the asteroid and has a bigger radius of effect as well.

To simplify the problem, the turret can decide to fire right away. Then we need to only figure out the angle of firing and distance of detonation. Also, there may be the case where the asteroid has already passed the area where it could be hit, meaning there is no solution!

You should download the unity source provided along with this tutorial to see the solution in action. We will see how we derive that solution.

2. The Solution

We are going to do a little refresher of our high school mathematics in order to find the solution. It is very straightforward and involves solving a quadratic equation. A quadratic equation looks like axˆ2 + bx + c = 0, where x is the variable to be found and it occurs with the highest power of 2. 

Analysing the Problem

Let us try to represent our problem diagrammatically. 

diagram of the incoming asteroid and the predicted path of missile

The green line shows the predicted path to be followed by the asteroid. As we are dealing with uniform motion, the asteroid moves with constant velocity. Our turret will need to rotate and fire the missile along the blue path for it to collide with the asteroid at a future time.

For uniform motion, the distance travelled by an object is the product of time and the object's speed, i.e. D = T x S, where D stands for the distance, T is the time taken to travel D, and S is the speed of travel. Assuming that our asteroid and the missiles would definitely collide, we can find the distance of the blue line followed by the missile in terms of time t. In the same time t, our asteroid will also reach the same position. 

Essentially, in the same time t, the asteroid will reach the collision position from its current position, and the missile will also reach the same collision position in the same time t. So at time t, both the asteroid and the missile would be at the same distance from the turret as they would be colliding with each other.

Enter Math

We can equate the distance from the turret to the asteroid and missile at this future time t in order to derive our quadratic equation with the variable t. Consider two points on a two-dimensional plane with coordinates (x1,y1) and (x2,y2). The distance D between them can be calculated using the equation below.

If we denote the turret position as (Tx,Ty), the missile speed as s and the unknown collision position as (X,Y), then the above equation can be rewritten as:

where t is the time taken for the missile to travel the distance D. Equating both, we get our first equation for unknowns X and Y with another unknown t.

We know that the asteroid also reaches the same collision spot (X,Y) in the same time t, and we have the following equations using the horizontal and vertical components of the asteroid's velocity vector. If the velocity of the asteroid can be denoted by (Vx,Vy) and the current position as (Ax,Ay), then the unknown X and Y can be found as below.

Substituting these in the earlier equation gives us a quadratic equation with a single unknown t

Expanding and combining similar terms:

Representing the power of two as ˆ2 and the multiplication symbol as * may have made the above look like hieroglyphics, but it essentially boils down to the final quadratic equation axˆ2 + bx + c = 0, where x is the variable t, a is Vxˆ2 +Vyˆ2 - sˆ2, b is 2* (Vx*(Ax - Tx) + Vy*(Ay - Ty)), and c is (Ay - Ty)ˆ2 + (Ax - Tx)ˆ2. We used the equations below in the derivation.

Solving the Quadratic Equation

To solve a quadratic equation, we need to calculate the discriminant D using the formula:

If the discriminant is less than 0 then there is no solution, if it is 0 then there is a single solution, and if it is a positive number then there are two solutions. Solutions are calculated using the formulas given below.

Using these formulas, we can find values for the future time t when the collision will happen. A negative value for t means we have missed the opportunity to fire. The unknowns X and Y can be found by substituting the value of t in their respective equations.

Once we know the collision point, we can rotate our turret to fire the missile, which would definitely hit the moving asteroid after t secs.

3. Implementing in Unity

For the sample Unity project, I have used the sprite creation feature of the latest Unity version to create the necessary placeholder assets. This can be accessed with Create > Sprites > as shown below.

Implementing in Unity

We have a game script named MissileCmdAI which is attached to the scene camera. It holds the reference to the turret sprite, missile prefab, and asteroid prefab. I am using SimplePool by quill18 to maintain the object pools for missiles and asteroids. It can be found on GitHub. There are component scripts for missile and asteroid which are attached to their prefabs and handle their motion once released.

The Asteroids

Asteroids are randomly spawned at fixed height but random horizontal position and are hurled at a random horizontal position on the ground with a random speed. The frequency of asteroid spawning is controlled using an AnimationCurve. The SpawnAsteroid method in the MissileCmdAI script looks as below:

The Launch method in the Asteroid class is shown below.

As seen in the Update method, once the asteroid has traveled the predetermined distance to ground, deployDistance, it would return to its object pool. Essentially this means it has collided with the ground. It would do the same on the event of collision with the missile.

The Targeting

In order for the auto-targeting to work, we need to call the corresponding method frequently to find and target the incoming asteroid. This is done in the MissileCmdAI script in its Start method.

The FindTarget method loops through all the asteroids present in the scene to find the closest and fastest asteroids. Once found, it then calls the AcquireTargetLock method to apply our calculations.

AcquireTargetLock is where the magic happens as we apply our quadratic equation solving skills to find the time of collision t.

Once we find the point of impact, we can easily calculate the distance for the missile to travel in order to hit the asteroid, which is passed on through the deployDist variable onto the LockOn method of the missile. The missile uses this value to return to its object pool once it has travelled this distance the same way as the asteroid. Before this happens, it would have definitely hit the asteroid, and the collision events would have been triggered.

Conclusion

Once we implement it, the result looks almost magical. By reducing the aiPollTime value, we can make it an invincible AI turret which would shoot down any asteroid unless the asteroid speed becomes close to or higher than our missile speed. The derivation we followed can be used to solve a variety of similar problems which could be represented in the form of a quadratic equation. 

I would like you to experiment further by adding the effect of gravity to the motion of the asteroid and missile. This would change the motion to projectile motion, and the corresponding equations would change. Good luck.

Note also that Unity has an active economy. There are many other products that help you build out your project. The nature of the platform also makes it a great option from which you can better your skills. Whatever the case, you can see what we have available in the Envato Marketplace.


Envato Elements Now Includes WordPress Themes & Plugins!

$
0
0

If you work with WordPress, you're in luck—WordPress themes and plugins are now included in an annual Envato Elements subscription. And what's more, you can lock in a special introductory rate for a limited time. Read on for more details.

Adios theme on Envato Elements

What's Included

Envato Elements already gives you unlimited downloads from a massive library of 400,000+ photos, graphics, templates, and other creative assets. Plus it gives you free access to more than 1,000 courses and 240 eBooks here on Envato Tuts+.

From today, you'll still get all of that plus a curated collection of beautiful, premium WordPress themes and plugins. 

As with everything else on Envato Elements, this is an "all you can eat" deal. You can download as many themes and plugins as you want, with no limits or credits to keep track of. And there's a simple licensing system so that you know you're covered for all of your projects.

Right now, there are over 190 top themes and 130 plugins available to choose from, and you can expect that number to grow as more authors join the platform and existing authors upload more items. 

WordPress Themes

There's a wide range of premium themes on offer, whether you're looking for a multipurpose theme suitable for a corporate audience or something more creative that would work for a blog or portfolio site. There are even niche themes for real estate sites, wedding sites and more—and of course, you can find e-commerce themes to help you make sales from your site.

Focuson theme on Envato Elements

WordPress Plugins

A well-designed theme is a great start, of course, but if you're working with WordPress you'll also need access to premium plugins to add the features and functionality you want.

Envato Elements has you covered here too, with a selection of powerful plugins to help you create booking and scheduling systems, contact forms, responsive menus, social media feeds, and more.

FlyFly WordPress plugin on Envato Elements

What It Costs

It's important to understand that WordPress themes and plugins are only available with an annual subscription, not a monthly one. Usually, an Envato Elements subscription costs $29 a month, so the annual subscription will be $348 a year ($29 x 12).

However, for a limited time, you can save $120 on your subscription and sign up for just $228 (the equivalent of $19 a month). Remember, for that price you get not only the WordPress themes and plugins but also thousands of photos, fonts, graphics, templates and more. It's a pretty special deal.

So head over to Envato Elements to see what's on offer, and if you like what you see, sign up for an annual subscription to start making unlimited downloads. Don't spend too long thinking about it, though, because this introductory deal won't last forever!

Start Saving With These Early Cyber Monday Deals

$
0
0

At Envato this year, Cyber Monday lasts a whole week. You can get 50% off selected items on Envato Market, or save a whopping $120 on an annual Envato Elements subscription, any time between now and next Wednesday, 29 November. 

So if you're looking for Photoshop actions, WordPress themes, stock photos, video footage, music or a wide array of other creative digital products, you can snag some impressive savings. Just visit the Cyber Monday Sale page to get the full details and start saving.

Cyber Monday sale details

50% Off 500 Envato Market Items

For the Cyber Monday sale on Envato Market, 500 popular items have been marked with special 50% reductions. 

So you can build a new site with top themes, add functionality with code, design with stunning add-ons and templates, or bring your projects to life with audio and video files. All at half the normal price.

You can browse all the discounted items on the sale page

Envato Market sale items

Save $120 on an Envato Elements Annual Subscription

If you just want one or two specific items, the Envato Market sale above is the one for you. But if you regularly use fonts, graphic templates, WordPress themes and other creative assets, an Envato Elements subscription is the best deal in town.

For $228 (the equivalent of $19 a month), you get a whole year of unlimited downloads from the huge library of 400,000+ stock photos, WordPress themes and plugins, icons, fonts, presentation templates, and much more.

Envato Elements homepage

And on top of that, you also get free access to unlimited Tuts+ courses and eBooks. So it's the perfect way to improve your skills while having access to all the digital assets you'll need for your creative projects throughout the year. It's an investment that will pay off many times over.

Don't Miss Out!

Remember, all of these deals end on 29 November, at 2 pm AEDT (Australian Eastern Daylight Time). Yes, that's Australian time, so if you're in Europe, America or other points east, you should make sure you've done all your shopping by Tuesday, 28 November at the latest. After that, the prices go back to normal.

You can find more details on all of these deals and links to the discounted items on the Envato Cyber Monday Sale page. So head over there to stock up on all the digital assets you'll need for the coming year, at unbeatable prices.

Create an Animated Movie in Blender: Part 1

$
0
0
What You'll Be Creating

Blender 3D is a versatile program with many great tools and resources. It's no wonder why many studios both small and large are using it to fully create their animated movies. You can search for "Big Buck Bunny" and "Sintel" to see examples of the power of Blender.

In this tutorial, you'll learn how to create an animated movie scene by scene in Blender. We will discuss environments, lighting, animation, and text. Finally, we will discuss how to render your scene and export it into a video format.

Creating an Environment

Setting the stage

In our scene, we will set up a stage, two curtains, and our character. We will add animation, sound, and camera movement. Once you understand how to complete all the aspects of this scene, you will have the necessary tools to create your own scene in Blender.

Throughout your project, you will be using textures, backgrounds, and assets. This would be a good time to create folders to help keep your project organized. Once you have created your folders, it is time to open up Blender and prepare your environment. For our sample scene, we are adding a stage using two planes and placing our character at the center of the stage. Therefore, you will need a character rigged for animation, and you will also need to add two separate textures.  

Let's start by going to add > plane from the menu on the bottom, and add another plane so that you have two planes in your viewport. Rotate one plane to use it as a back wall. Resize and adjust. 

We will now add two textured images. If you haven't done so, you will need to make sure you have images as planes enabled in the user settings. Now it's time to add the texture in the materials section of the Hierarchy. We will need a wood texture for the stage and a red curtain texture for the curtains (attached).

Lighting & HDR

Lighting  HDR

Lighting is one of the most important tools in your scene. If you have bad lighting, not only will the end result be dark, but images and objects won't render correctly. You may already know how to set up lamps, possibly a three-point lamp setup. For the purpose of our scene, we are using 3 spotlight lamps for the curtain effect and HDR (High Dynamic Range) lighting for the scene.

HDR lighting can make your scenes look evenly bright and realistic. HDR maps can be pricey, but they are well worth it. They can bring sharp, vivid lighting to your scene. The makers of Blender Guru provide free HDR maps as well as tutorials on setting it up.

To add your HDR, click the world icon, and then add an environment texture. Under the color, select open and open the .hdr file. You can tweak it in your settings, and you can also change the brightness and horizon lines.

Add a Character

Adding a character

Time to import our character and add animation. Go to file > import and import your character into the scene. You can move your character in object mode by selecting all of his bones. 

Tip: Clicking A on the keyboard twice selects all.

Working on the character model

Let's change to the animation view. A great tip for animating is spacing out the keyframes appropriately. The more you space them out, the more seamless your animation will be.

In this scene, I moved my character's head slightly and opened his mouth in the cue of the soundtrack we are going to use later in this tutorial. 

Tip: If you need assistance on animating your character, feel free to check out my article on animating a character in our tutorials section.

Now it's time to add our curtains. Add two images as planes. Change the material with the file included in this tutorial. Animate the plane so that it moves in and out of the scene. 

Moving Our Camera

Time to animate our camera. Blender treats a camera as an object; it can be moved, deleted, resized, or animated. To see where your camera is pointing, go to view > camera. 

In the animation menu, set up your view side by side by side. Click your camera and set up your keyframe. You can now move your camera closer to your character, set the keyframe, move it backward, and set it again. See the video below.

Adding Text

Adding test to the screen

At the end of this scene, we are going to add a title. Adding and animating text in Blender is easy as pie. Let's go to the default window > add > text. If you go to edit mode, you can change the text, duplicate, or add more. 

Text is also considered an object, so you can change the color and texture and animate it in the same way.

Conclusion

We are going to place our text behind the stage, wait for our character to sing, and then have the title animate to the front of the curtain while it closes. You can have fun with the text and have it spin, move up and down, etc. 

Stay tuned for part two of this tutorial, where I show you how to render your scene and export it as a movie.

Create an Animated Movie in Blender: Part 2

$
0
0
What You'll Be Creating

In part two of this series on creating an animated movie in Blender, we will discuss how to properly render your scene, add sound, and prepare your video for export.

Rendering Your Scene

Rendering your scene as a PNG

Now that you have done the work, it's time to render your scene. As an animator or designer, you will find that rendering your scene takes time and practice. Blender has a wonderful community that can assist you, with great tips on many assorted topics. 

Rendering an animation involves saving still images of your scene. Here are some tips on rendering your scene fast and with fewer fireflies.

  1. Make sure to set up a separate folder for your images.
  2. Render all of your scenes as a PNG.
  3. Uncheck Reflective & Refractive Caustics.
  4. Lower the Bounces to Min 1-Max 10.
  5. Use your GPU not CPU to render. (You can check which one you are using in User Settings > System).
  6. Use Multiple Importance Sampling (you can find this under the world icon for your HDR, as well as your lamps).
  7. Use Clamp Indirect.
  8. The higher the Samples, the clearer the scene (be patient—masterpieces take work!).
  9. Download the most recent Blender program. I hear Blender 2.79 has a Denoise option.
  10. Trial and error—computer systems are different, and scenes are unique. You will need to play around with all of the above until you find the perfect method for you.

Video Editing

Blender comes with an internal video editor which you can use to add sounds and filters and export your scene into a video format. It is easy to use and works seamlessly with your PNG files.

Editing the video

Once you have rendered your scene into separate images, open a new Blender project. Change from the Default menu to Video Editing in your viewport. Start on frame 1, click add > images, and go to the folder containing your still images. Press the A key to select all images, and then open. 

You will now see your animation strip in the video editing viewport. Click play; if it plays too fast, you will need to slow it down by lowering the frame rates. By default, it is on 24. I set mine to 7, as you can see in the above example.

Tip: Use the middle mouse button to zoom into your strip for editing.

Adding Sound

Audio format

Let's add some sound to our scene. We will need to search for an applause and singing clip sound effect. If you plan on animating often, it would be a good idea to purchase a membership with a sound effect site like AudioJungle

There are also a few good sites for royalty-free sound effects. For this scene, let's go to freesound.org. You can sign up for free. I searched for an applause sound along with an opera song clip and saved it in a folder called sound effects. 

Next, we will add our sound effects to the video. As you can see, in the sample above there are separate channels. Add the applause sound effect to start at 1, and then add the song clip followed by the applause sound effect. You will need to move them accordingly to sync them with your frames. Hit play. Once you are happy with the sync and speed, it's time to export.

Tip: Use your right mouse button to move the strips to where you need them.

Video Export & Conclusion

In your video editing viewport, you should have a window for properties. In this window, you will see the frame rate and export folder options. Under output, you will use H264 with an AVI codec, and also use the MP3 format for our audio. Click render, and within a minute or two you will have your final video in your folder. Click play, tweak, and you are done!

Keep Things Clear: Don't Confuse Your Players

$
0
0

Playing a game can be a complex task. Some games, like Snakes and Ladders, are pretty straightforward—but some games, like SpaceChem or Factorio, can be incredibly complicated affairs that test our brains to the very limit.

For every game, from simple to complex, it's important that the player knows how to play. If it's just throwing dice or doing complex mathematical equations, it doesn't matter—as long as the player knows how the game works.

But for some games, we make things unnecessarily difficult. For most games, there are very clear sets of rules, and any actions the player takes should have expected outcomes—but sometimes, things can get muddled. Let's have a look at some of the common pitfalls regarding this, and how we can try to avoid them.

Clear Rules

The first thing is to keep the rules consistent. Games are generally built around the idea of challenges and progress, and we use rules to determine how well the player is doing. A player should generally have a clear idea of what they want to accomplish, because a game without challenge isn't a game—it's a toy. There's nothing wrong with making toys—Minecraft is pretty successful—but games need rules, and it's not fun for the player if the rules keep changing every ten seconds.

One way that games change the rules is by making some characters immortal. RPGs are most often guilty of this, giving certain NPCs “plot armour”—because if they die then the player is stuck, unable to complete important quests. 

Having immortal NPCs breaks immersion, and while you don't want the players to be unable to finish the game, you do need to try and keep the rules of your world consistent. 

Often, immortal NPCs won't even be clearly marked, meaning that sometimes the player can be wailing on an enemy that can't even take damage. If you want to have immortal NPCs, try to have them clearly marked—or just let them be killed. 

There's nothing wrong with that (Planescape: Torment did it, and is one of the best RPGs ever made), and you can just tell the player that they screwed up and can't win.

Invisible walls are another "rulebreaking" design aspect that seems to pop up time and time again. It's not fun to be exploring and come up against a barrier that prevents further progress. Sometimes, these barriers serve no purpose other than to force players into taking long detours, artificially increasing playtime. 

In some cases, invisible barriers can be necessary: there does need to be an upper limit to how far off the map the players can move, and an invisible barrier can achieve this. But when players find these invisible walls in normally accessible areas, too often it feels like poor design and lazy planning.

Fortnite BR
Now patched, early versions of Fortnite: Battle Royale had invisible wall problems with its walls. The holes in these walls would allow you to see through, but still blocked bullets, meaning combat could be pretty confusing if you tried to catch someone unaware.

And lastly, don't unexpectedly change the rules halfway through the game. Choices in games are based on information, and having bad information means bad choices. One example of this in video games is in Deus Ex: Human Revolution, where players who had been playing as stealth characters suddenly hit brick walls in the form of bosses that were only beatable via combat. 

Later patches fixed this, but if you give a player the option to play a non-combat character, you can't act surprised when they pick it. Cutscene quick-time events are also susceptible to this, as most cutscenes are non-interactive, meaning that when a quick-time event does happen it breaks the player's expectations.

Interestingly, this rule was subverted in South Park: the Fractured but Whole. When fighting against Cartman, he breaks established rules during the fight—ignoring damage, taking extra turns, warping around, and so forth. South Park fans will realise that this sort of blatant cheating is entirely consistent with Cartman's character, and while the fight can initially be frustrating, it makes you hate the character that little bit more and adds to the overall game experience.

Clear Goals

When we make our game, we design objectives for the player and ways for the player to reach that objective. When the rules are clear, then it's also clear how the player achieves their goal. But what if the goal isn't clear? What if the player has clear rules, but isn't sure what they're actually supposed to do?

For some games, this “fuzzy objective” approach is fine—Minecraft has little in the way of an overarching plot, but the player is still able to make clear goals. Whether slaying an elder god, reassembling a key or building a pickaxe, games are defined by goals, so it's important that the player understands these goals well.

For puzzles, don't hide puzzle pieces from the player. Of course, it's fine to make them work for it, but if a player spends 20 minutes trying to work out how to open a door and then you say “Haha, there was a key hidden here all the time”, the player might feel a little ticked off. In some older games this was referred to as “pixel hunting”, a process which hid important game elements in tiny screen locations, forcing stuck players to weave the mouse back and forth over every single game location hoping to pick up something they had missed.

Indiana Jones image
In this screen from Indiana Jones, the player must examine every single book to find the one that says "book" rather than "books". Have fun.

Ensure that game elements are clearly displayed as game elements. This applies to all games, but doubles for puzzle games. If a player can't solve a puzzle, you show them the solution, and then they say “Oh, I didn't realise you could interact with that” then you have failed the player as a designer. 

We accept that not all game elements can be interacted with, so it's bizarre when an important game element is hidden as background imagery. Several games have managed to avoid this by allowing the player to hold down a key to highlight items you can interact with, which is a simple addition that works nicely.

Draw a stickman image
Draw a stickman: Epic. The player has to get past some bees, and the only power they have is rain and lightning. The bees are seemingly immune to both. The solution? Rain on the flowers, making them bigger, attracting the bees. If you thought that the flowers were just part of the background, then you wouldn't get very far.
South Park image
In South Park, elements the player can interact with are coloured bright yellow: the fridge and the two cupboards. This simple colouring lets players know what is available for the player to interact with. 

Graphic clues can be incredibly useful for setting goals. When a player has an objective, it makes sense for it to be something they can mentally connect with. The reason Mario collects coins is because coins are an obvious object to collect. 

In Plants vs. Zombies, the player's turrets are plants because they can't move, and you defend against zombies—a horde of slow-moving enemies. If a game element is causing trouble for a player, ask yourself why. If it's because of a logical disconnect, consider redesigning the enemy, ability, or whatever it is.

And try to ensure that if the player is on the correct track to solving something, you don't throw them off the track just because they didn't get it exactly correct. An old example of this comes from the originalMonkey Island game, where the player had to retrieve a jug of alcohol from a sleeping pirate using a feather. 

Tickling the pirate elicited: “I can't find a ticklish spot on his body.” Tickling the pirate by specifically clicking on this foot, however, did work. The response the game gives not only isn't helpful, it makes the player think that a completely different solution is needed.

Monkey Island image
Part of the issue with this puzzle is that the game lists the pirate and the foot as "sleeping ghost crew". If the foot had been listed as "ghost crew's foot", then the puzzle would have been clearer.

Clear Action

Finally, we need to make sure that the player's actions are clear. We have rules, and we have goals, so the player should understand what happens when they try to apply the rules to reach those goals.

To simplify this, let's say you're making a Mario clone. When you press the jump button, you normally jump, but there is a 1% chance that the character ducks instead. Hopefully, you're thinking to yourself: “That sounds pretty stupid.” So why do we keep seeing this sort of design in games?

One of the biggest culprits for this is context-sensitive commands. Sometimes it works, and sometimes it doesn't. But when you play a game like Diablo 3 on a console, you notice quickly that the “basic attack” button is also the “interact with” button, meaning that fights near portals can end up with some unintentional warping around. Prince of Persia had the “jump” and “wallrun” commands on the same button, which worked for the most part, but you'd occasionally activate the wrong one and run straight into a death trap.

Trying to take an action at the wrong time can occasionally be frustrating to players as well. Because computers run at thousands of commands per second, it can be difficult to press the right button at exactly the right millisecond. If the player needs to jump over a series of pit traps, then missing a single jump because you pressed the jump button a fraction of a second too early can be another frustrating factor. 

What some games have done to combat this is use something called “input buffering”, which means “holding” a command for a set period of time—say, 5 frames—and hold it for the next free action. It's also possible to allow the user to take actions after it's too late. If a player runs off a ledge and then hits the jump button, it's not unreasonable to allow the player a frame or two of leeway. This isn't necessary for all games, but for games that rely on quick reaction times, it can often be much more enjoyable than simply punishing a player who just missed that reaction window. Just don't overdo it.

Another point, and perhaps one of most important, is to make sure that the player can actually see what's happening on screen. It's very tempting to add lots of cool sparkly effects and particles, but if we add so much to the screen that the player has no idea what's going on, then it makes it pretty difficult for them to play. 

One of the worst offenders for this is The Binding of Isaac, in which it's not terribly hard to get so many weapons upgrades or followers that it becomes literally impossible to see what's happening on screen. But other than that, the game seems to take a perverse delight in making things artificially hard at times—the “curse of darkness” makes everything on screen darker, making it more likely that you'll run into an enemy or trap that you didn't even know existed. 

Similarly, some enemies produce “creep”, which is a dangerous substance left on the ground that causes contact damage. While on most levels the creep is clearly visible, on some levels it blends in with the red background, becoming nearly invisible.

Binding of Isaac image
In this image, some... stuff... is happening. I have no idea. You can just make out a door to the right.
Binding of Isaac image
In this image, there are two patches of creep active: one to the left, beside the door, and one to the right, beside the battery. Both will kill you.

And finally, slightly looping back to an earlier point, try to make sure that when the player takes an action, they are not surprised by odd results. Specifically, we're going back to talking about invisible walls, but a specific type of invisible wall: namely, blocking objects. Some games treat the player like a rectangular pillar, meaning that the only way past a tiny object—say, a small pebble—is to avoid or jump over it. 

Of course, in real life a pebble can make us stumble, but it's not something that needs to be modelled in game. So when a player is moving around a 3D environment, consider making the player slide past small objects, or don't give them physical bodies at all. The old Half-Life engine games (such as Team Fortress 2) were notoriously bad for this, and players could get stuck on all sorts of objects in game.

Team Fortress 2 image
Standing quite casually on an exit sign. Yes, that tiny little sign attached to the wall will quite happily support a man's weight.

Bringing It Together

Although it seems as if a lot of these points might only be tangentially related, they're all really just the same point expressed in different ways: there should be clarity between the user and the game. If the player doesn't know what's happening, then they can't make good choices.

Of course, some games make a sort of meta-game out of trying to understand the rules—setting the player a puzzle, but not telling them the objective. Sometimes this works, and sometimes it doesn't. The Witness did this, and while it's pretty highly rated, it's also quite a divisive game. Those that like it seem to love it, and those that don't… probably won't get more than five minutes into it before getting bored. 

Regardless, this obscurity doesn't hurt the game because it is the game. There's still plenty of room out there for games where players have to explore and find out how things work—and besides, telling the players how everything works can take away some of the fun.

Overall, like anything else, just make sure the player is having fun. When the player is confused, they're probably not engaged. When a player dies because of something they couldn't have predicted, then they'll quickly become frustrated. But when a player makes a choice, and that choice pays off, then they'll feel rewarded and will want to play more.

How to Create a Low Poly Tree in Cinema 4D

$
0
0
Final product image
What You'll Be Creating

Follow this tutorial step-by-step to create a low poly tree model that you can use in video games, graphic design and illustration projects whilst learning Cinema 4D quickly.

Some of the skills you'll learn in this tutorial include creating basic 3D shapes, extrusion techniques, basic rendering techniques and how to colour 3D objects.

1. How to Create a Cube

Step 1

Open Cinema 4D and take a look at the top menu bar of the screen. You'll find almost all the tools that you will need to create the floating island. 

Select a new project in Cinema 4D and enter Perspective Mode by selecting it with the mouse.

Four different views in Cinema 4D

Step 2

Navigate the mouse to the top of the screen and click on the Add Cube Object button in the top menu bar.

Primary-Click and Hold on the blue Add Cube Object button. This reveals a sub menu where you can click to create more objects. This will come in handy later on in the project. Create the Cube tool by clicking on it.

Clicking the Add Cube Object button

Step 3

Make sure that the cube is selected and then click on the Make Editable button in the menu bar on the left of the screen.

Clicking the Make Editable button

2. How to Extrude Polygons from a Cube

Step 1

Select the Polygons button on the left side of the screen. This allows you to select the polygons on the cube.

Clicking the Polygons button

Step 2

Click the polygon that you would like to extrude. The polygon will appear highlighted in yellow. Hold the Control Button on the keyboard and use the mouse to hover over the direction you want to move the polygons to. For this example we will use the y axis (green arrow). 

The mouse cursor should change shape, indicating that you can move the polygons. Whilst holding the Control Button, click and drag the arrow to extrude the polygons.

Extruding the polygons from the cube object

Step 3

Choose from any of the polygons sides in order to extrude the object to the shape that you want.

Extruding polygons in different directions

3. How to create the Tree Trunk

Step 1

Use the Scale Tool to create a tapered look to the tree trunk. Make sure to select the top polygon first using the Polygons button.

Selecting the Scale Tool button

Step 2

Click and drag the axis using the scale tool to taper the top of the cube.

Scaling down the top polygon

Step 3

Extrude the polygons and use the Move Tool to change the direction of the tree trunk to give it an interesting shape.

Extruding polygons from the base

Step 4

Remember to taper the top polygon by using the Scale Tool.

Scaling down the top polygon

Step 5

Repeat the previous steps a few more times, using the Scale Tool and the Move Tool, until you are happy with the shape of the tree trunk.

Modelling the tree trunk

4. How to create Tree Branches

Step 1

To create the branches select the polygon for it's point of origin using the Polygons button.

Once you have a polygon selected, secondary-click the mouse to bring up a menu and select Bevel from the list of options.

Selecting the bevel tool

Step 2

Click and drag on the selected polygon until you are happy with the shape of the bevel.

Using the bevel tool

Step 3

Use the Move Tool to extrude the branch out. Hold the Control Button on the keyboard whilst using the mouse to click and drag the selected polygon.

Extruding polygons for the branch

Step 4

Taper the branch using the same techniques used to taper the tree trunk. Play around using the Move Tool and the Scale Tool to get the best results.

Using the scale tool to taper the branch

Step 5

Keep extruding and tapering the branch out until you are happy with the overall shape. Remember to use the Move Tool to send the branch out into different directions.

Modelling and shaping the branch

Step 6

Choose another polygon on the branch and extrude another shape out.

Extruding and shaping the branch

Step 7

Repeat the steps above to create a second and third branch. Make sure to view the tree from different angles in the viewport. This will give you the most interesting shapes for the tree.

Creating a second branch
Creating a third branch

5. How to create Low Poly Leaves

Step 1

Navigate to the top menu and click and hold on the Cube Button. This reveals a menu with options to create more shapes. Select the Sphere. This will spawn a sphere in the scene.

Selecting the Sphere button

Step 2

Navigate to the top menu and click and hold the Bend Button. This will reveal another set of options. Select Polygon Reduction.

Selecting the Polygon Reduction button

Step 3

Drag the Polygon Reduction into the Sphere. This will reduce the amount of polygons in the sphere.

Dragging the Polygon Reduction into the Sphere

Step 4

Make sure Polygon Reduction is still selected. In the bottom window change the Reduction Strength until you are satisfied with the results.

Adjusting the Polygon Reduction strength setting

Step 5

Navigate to the top menu and click and hold the Bend Button again. This reveals another set of options. This time select Displacer.

Selecting the Displacer button

Step 6

Drag the Displacer into the Sphere. This changes the shape of the sphere and add more options.

Dragging the Displacer into the Sphere

Step 7

With the Displacer still selected, navigate to the bottom of the screen where the Displacer options are located. Select the Shading tab and click the arrow button next to Shader. Select Noise from the drop down menu.

Adjusting the Displacer settings

Step 8

Select the Object tab and adjust the Height until you are happy with the way the sphere looks.

Adjusting the Displacer settings

Step 9

Select the Sphere then select the Scale Tool. Make sure that the Model button is selected and use the Scale Tool to adjust the shape of the sphere until you are happy with it's shape.

Scaling the sphere object

Step 10

Use the Move Tool to position the sphere correctly on the tree. Using all four views in the viewport can help with this. To do this, click on the middle button on the mouse.

Using the Move Tool to position the sphere

Step 11

Duplicate the Sphere by holding the Control Button and clicking and dragging the Sphere Object.

Duplicate the sphere object

Step 12

Move the new sphere to another position on the tree using the Move Tool. Adjust the look of the new sphere by selecting the Displacer and using the options as outlined in the previous steps.

Duplicating more spheres

Step 13

Continue to duplicate and position new spheres to create a look that you are happy with.

Creating the look of low poly tree leaves

Step 14

Repeat the steps to create leaves for the other branches of the tree.

Creating more low poly tree leaves

6. How to Group Objects

Step 1

Select all the Sphere Objects that belong to a group of leaves. Group objects by holding the Shift Key on the keyboard and selecting objects with the mouse.

Selecting a group of sphere objects

Step 2

With the objects selected press Alt-N to create a new group.

Grouping sphere objects together

Step 3

Use the mouse to select the Null Group and rename the group with a suitable name.

Renaming the group object

Step 4

Repeat the steps for each sphere group.

Renaming all the group objects

7. How to Colour Objects

Step 1

At the bottom of the screen click on the Create Button and select New Material.

Selecting the New Material button

Step 2

Double click on the Material and a new window will appear. Untick Reflectance.

Untick Reflectance in the Material Editor

Step 3

Select Colour and double click on the box at the top of the window.

Selecting the colour box

Step 4

Select a suitable colour for the tree trunk and then click the OK button.

Using the colour picker

Step 5

Apply the material to the tree trunk by clicking and dragging it to the object using the mouse.

Dragging the new material into the tree trunk

Step 6

Repeat the steps to create several different coloured materials for the leaves. 

Selecting new colours for more materials

Step 7

Apply the materials to the grouped objects.

Adding the new materials to the tree leaves

8. How to add Light to the Scene

Step 1

Choose a suitable angle in the viewport by navigating around the scene. Click on the Camera button at the top to create a camera.

Selecting the Camera button

Step 2

To set up the basic lighting, you’ll want to go to the Floor button located in the top menu bar. Left Click-Hold and then select Physical Sky from the menu.

Selecting the Physical Sky button

Step 3

Ensuring that Physical Sky is selected in the menu on the right, a new menu will appear on the bottom right of the screen. Select the Time and Location tab and choose a time using the left and right arrow keys. This will change the lighting of the scene. Choose a suitable time to light up the scene.


Adjusting the Time and Location

Step 4

To add additional lighting to the scene, select the Add Light button in the top menu bar at the top of the screen.

Selecting the Add Light button

Step 5

This will create a Light Object which you can move around the scene. Move the light object using the Move Tool to a suitable position.

Using the Move Tool to position the Light Object

Step 6

To customise the lighting further, experiment with the light object options in the bottom right of the screen. Here you can adjust the Intensity, Light Type and even Colour.

Adjusting the light settings

9. How to Render the Scene

Step 1

Click on the Render Settings button on the top menu bar.

Selecting the Render Settings button

Step 2

Choose the resolution, height and width of the image. This tutorial uses the settings 1920x1200 72dpi.

Adjusting the render settings for output

Step 3

Choose where you'd like to save the file and the file name. You may wish to tick Alpha Channel on, if you want to continue editing the image in another program such as Adobe Photoshop.

Adjusting the render settings for save

Step 4

Go to the Effect button at the bottom left and select both Ambient Occlusion and Global Illumination from the drop down menu. This will add these options to the render.

Selecting Ambient Occlusion and Global Illumination

Step 5

Click the Render button and wait for the render to finish.

Selecting the Render button

Conclusion

And with that, the 3D Low Poly Tree is complete. Feel free to share the own creations below. Explore different camera angles, lighting set ups and colours to find out what works best for the illustration.

You can also export the image to Adobe Photoshop to enhance it further or to use it as part of a larger scene or illustration. 

The final render of the low poly tree

Unity 2D Tile-Based Isometric and Hexagonal 'Sokoban' Game

$
0
0
Final product image
What You'll Be Creating

In this tutorial, we will be converting a conventional 2D tile-based Sokoban game into isometric and hexagonal views. If you are new to isometric or hexagonal games, it may be overwhelming at first to try following through both of them at the same time. In that case, I recommend choosing isometric first and then coming back at a later stage for the hexagonal version.

We will be building on top of the earlier Unity tutorial: Unity 2D Tile-Based Sokoban Game. Please go through the tutorial first as most of the code remains unchanged and all the core concepts remain the same. I'll also link to other tutorials explaining some of the underlying concepts.

The most important aspect in creating isometric or hexagonal versions from a 2D version is figuring out the positioning of the elements. We will use conversion methods based on equations to convert between the various coordinate systems.

This tutorial has two sections, one for the isometric version and the other for the hexagonal version.

1. Isometric Sokoban Game

Let's dive right in to the isometric version once you have gone through the original tutorial. The image below shows how the isometric version would look, provided we use the same level information used in the original tutorial.

the isometric version of the sokoban level

Isometric View

Isometric theory, conversion equation, and implementation are explained in multiple tutorials on Envato Tuts+. An old Flash-based explanation can be found in this detailed tutorial. I would recommend this Phaser-based tutorial as it is more recent and future proof.

Although the scripting languages used in those tutorials are ActionScript 3 and JavaScript respectively, the theory is applicable everywhere, irrespective of programming languages. Essentially it boils down to these conversion equations which are to be used to convert 2D Cartesian coordinates to isometric coordinates or vice versa.

We will be using the following Unity function for the conversion to isometric coordinates.

Changes in Art

We will be using the same level information to create our 2D array, levelData, which will drive the isometric representation. Most of the code will also remain the same, other than that specific to the isometric view.

The art, however, needs to have some changes with respect to the pivot points. Please refer to the image below and the explanation which follows.

isometric sprites and their offsets

The IsometricSokoban game script uses modified sprites as heroSprite, ballSprite, and blockSprite. The image shows the new pivot points used for these sprites. This change gives the pseudo 3D look we are aiming for with the isometric view. The blockSprite is a new sprite which we add when we find an invalidTile.

It will help me explain the most important aspect of isometric games, depth sorting. Although the sprite is just a hexagon, we are considering it as a 3D cube where the pivot is situated at the middle of the bottom face of the cube.

Changes in Code

Please download the code shared through the linked git repository before proceeding further. The CreateLevel method has a few changes which deal with the scale and positioning of the tiles and the addition of the blockTile. The scale of the tileSprite, which is just a diamond shape image representing our ground tile, needs to be altered as below.

This reflects the fact that an isometric tile will have a height of half of its width. The heroSprite and the ballSprite have a size of tileSize/2.

Wherever we find an invalidTile, we add a blockTile using the following code.

The hexagon needs to be scaled differently to get the isometric look. This will not be an issue when the art is handled by artists. We are applying a slightly lower alpha value to the blockSprite so that we can see through it, which enables us to see the depth sorting properly. Notice that we are adding these tiles to the occupants dictionary as well, which will be used later for depth sorting.

The positioning of the tiles is done using the GetScreenPointFromLevelIndices method, which in turn uses the CartesianToIsometric conversion method explained earlier. The Y axis points in the opposite direction for Unity, which needs to be considered while adding the middleOffset to position the level in the middle of the screen.

At the end of the CreateLevel method as well as at the end of the TryMoveHero method, we call the DepthSort method. Depth sorting is the most important aspect of an isometric implementation. Essentially, we determine which tiles go behind or in front of other tiles in the level. The DepthSort method is as shown below.

The beauty of a 2D array-based implementation is that for the proper isometric depth sorting, we just need to assign sequentially higher depth while we parse through the level in order, using sequential for loops. This works for our simple level with only a single layer of ground. If we had multiple ground levels at various heights, then the depth sorting could get complicated.

Everything else remains the same as the 2D implementation explained in the previous tutorial.

Completed Level

You can use the same keyboard controls to play the game. The only difference is that the hero will not be moving vertically or horizontally but isometrically. The finished level would look like the image below.

Isometric version finished level

Check out how the depth sorting is clearly visible with our new blockTiles.

That wasn't hard, was it? I invite you to change the level data in the text file to try out new levels. Next up is the hexagonal version, which is a bit more complicated, and I would advise you to take a break to play with the isometric version before proceeding.

2. Hexagonal Sokoban Game

The hexagonal version of the Sokoban level would look like the image below.

hexagonal sokoban level

Hexagonal View

We are using the horizontal alignment for the hexagonal grid for this tutorial. The theory behind the hexagonal implementation requires a lot of further reading. Please refer to this tutorial series for a basic understanding. The theory is implemented in the helper class HexHelperHorizontal, which can be found in the utils folder.

Hexagonal Coordinate Conversion

The HexagonalSokoban game script uses convenience methods from the helper class for coordinate conversions and other hexagonal features. The helper class HexHelperHorizontal will only work with a horizontally aligned hexagonal grid. It includes methods to convert coordinates between offset, axial, and cubic systems.

The offset coordinate is the same 2D Cartesian coordinate. It also includes a getNeighbors method, which takes in an axial coordinate and returns a List<Vector2> with all the six neighbors of that cell coordinate. The order of the list is clockwise, starting with the northeast neighbor's cell coordinate.

Changes in Controls

With a hexagonal grid, we have six directions of motion instead of four, as the hexagon has six sides whereas a square has four. So we have six keyboard keys to control the movement of our hero, as shown in the image below.

Hexagonal keyboard control keys

The keys are arranged in the same layout as a hexagonal grid if you consider the keyboard key S as the middle cell, with all the control keys as its hexagonal neighbors. It helps reduce the confusion with controlling the motion. The corresponding changes to the input code are as below.

There is no change in art, and there are no pivot changes necessary.

Other Changes in Code

I will be explaining the code changes with respect to the original 2D Sokoban tutorial and not the isometric version above. Please do refer to the linked source code for this tutorial. The most interesting fact is that almost all of the code remains the same. The CreateLevel method has only one change, which is the middleOffset calculation.

One major change is obviously the way the screen coordinates are found in the GetScreenPointFromLevelIndices method.

Here we use the helper class to first convert the coordinate to axial and then find the corresponding screen coordinate. Please note the use of the sideLength variable for the second conversion. It is the value of the length of a side of the hexagon tile, which is again equal to half of the distance between the two pointy ends of the hexagon. Hence:

The only other change is the GetNextPositionAlong method, which is used by the TryMoveHero method to find the next cell in a given direction. This method is completely changed to accommodate the entirely new layout of our grid.

Using the helper class, we can easily return the coordinates of the neighbor in the given direction.

Everything else remains the same as the original 2D implementation. That wasn't hard, was it? That being said, understanding how we arrived at the conversion equations by following the hexagonal tutorial, which is the crux of the whole process, is not easy. If you play and complete the level, you will get the result as below.

hexagonal sokoban finished level

Conclusion

The main element in both conversions was the coordinate conversions. The isometric version involves additional changes in the art with their pivot point as well as the need for depth sorting.

I believe you have found how easy it is to create grid-based games using just two-dimensional array-based level data and a tile-based approach. There are unlimited possibilities and games that you can create with this new understanding.

If you have understood all the concepts we have discussed so far, I would invite you to change the control method to tap and add some path finding. Good luck.


What's in a Name? Data Analysis of 5,820 Steam Games

$
0
0

What’s in a name? More than you’d think. Whether you’ve been working on your game for a long time or you’re just entering the planning stages, at some point you’re going to need a name. The title of a video game pushes the boundaries of our imaginations and causes us to recall memories. 

With more than 6,000 games being released on Steam each year, how many stir up player interest? Let’s take a look at some research we’ve done on titles released this year.

Why Are Titles Important?

Before we get into looking at the numbers, let’s quickly talk about why the name of a video game is so important. While it may seem like a minor part in the overall experience, the title is key—especially when it comes to marketing your game. In the fast-paced world of digital marketing, your title, a tagline, and an image or two may very well be the only thing a potential player sees. 

When searching through the Steam store, your title and a small image are all you have to promote your game. In the earlier ages of digital gaming, there was also a more limited amount of games being released overall. Pairing the glut of titles being released with this reduced marketing space makes a name more important than ever.

Beyond that, there are many other points to consider. Word-of-mouth marketing, search engine rankings, potential confusion with other existing titles, and more are all reasons to put extra effort into making sure your name is foolproof.

Now let’s take a look at the data.

Entire Set Statistics

We analyzed 5,820 games released this year (no free-to-play games included) to gather the following statistics. We focused on standalone titles released as their own product, so DLC and similar expansions were excluded from the data set. Brief explanations of the data and methods follow each data point.

Title Size

Of the 5,820 titles analyzed, the average title length in characters was 17.15, with a standard deviation of 10.26. So in general, games released this year ranged between approximately 7 and 27 characters, excluding outliers.

In terms of words, the average title length was 2.8 words with a deviation of 1.7, giving a general range between 1 and 5 words.

This shows a general trend towards more concise titles, which leaves two potential choices: following the trend, or deliberately avoiding it. Both offer distinct advantages in the current state of the market, and should be considered carefully when coming up with your own game title.

In addition to these ranges of character and word lengths, many of the games analyzed showed similar naming structures. From the early stages of analysis, there were less than two dozen title structures that accounted for more than 90% of the games. Of note is the current prevalence of titles using the structures “{noun} of {noun}” and “{noun}: {adjective} {noun}” (for example, West of Loathing and Divinity: Original Sin 2 respectively).

Title Size

Multi-Part Titles

15.14% of the total dataset was found to have a title with multiple parts. For the analysis, a title was considered to have multiple pieces when one of the symbols “:”, “-”, or “|” appeared and provided two distinct pieces of information. For example, “Yooka-Laylee” was not considered to have multiple parts, whereas “Steel Division: Normandy 44” was.

Unique Word Usage

One of the more interesting pieces of data collected was the usage of “unique words” within a game’s title. For our purposes, a word was considered unique if it did not exist as a dictionary definition within the ten most popular languages utilized by Steam players. Overall, 27.93% of titles were found to include a unique word within their title.

Unique Word Usage

References to Other Intellectual Property

Looking at our dataset for references to other Intellectual Properties (IPs) yielded a new subset that warrants further analysis later. 11.96% of the games in the dataset were found to reference a previous IP in some capacity—whether the IP was a previous game, movie, book, or other medium.

Using this subset to further research the relations between game sequels, movie-based games, and book-based games could make for an interesting project for those that want to do some number crunching of their own.

Measuring Up

Let’s look at how these titles stack up against top sellers. By looking at the top 10% of games and comparing them to the entire dataset, we can create a vivid picture of what’s important in video-game titles.

Title Size Comparison

The top 10% of games released this year, by sales, averaged a title length of 17.63 characters. Compared to the 17.15% of the general dataset, this shows that the top-selling games have a slightly longer title on average.

The average for title lengths by word count shows a similar result. The top games come in at 2.92 words, compared to the 2.8 words of the full dataset. Enough to show that the top games tend to be a little wordier.

Multi-Part Titles

19.17% of games in the top 10% of sales had multi-part titles, compared to 15.14% for the full dataset. The difference between these two numbers suggests that there may be a benefit to longer titles. This is likely due to the improved utilization of limited space developers have to attract potential players.

Usage of Unique Words

When it came to using unique words, the best-selling games were stellar! 48.19% of titles utilized at least one unique word, compared to just 27.93% of titles in general. This is a huge difference in data, and suggests that using unique words may make a game more memorable, or more likely to entice a would-be customer.

References to Other Intellectual Properties

In regards to other video games, movies, and books, top-selling games referenced them in 20.73% of cases—nearly double the 11.96% of the entire dataset. This shows a clear trend that extensions of existing franchises tend to perform better, or at least have a higher chance of being successful.

References to Other Intellectual Properties

Datasets, Sources, and Analysis Techniques

The dataset used for the research in this piece are provided entirely through SteamSpy and the Official Steam Web API. If you’d like to do your own research or try out other algorithms, those are the best places to start.

When reading through the data, keep in mind that limitations of the datasets and analysis techniques may have left gaps that could affect your results. For example, inherent issues exist, such as the effect of free weekends on sales data and games with sales equivalent to the margin of error.

While this data is still useful, these issues were difficult to control for.

Data Interpretation: What Does It All Mean?

We’ve gone over a lot of data, but what does it mean for you? Here are some of the clearest trends that we found:

Keep Titles Between 1 and 5 Words

Most games stay in this range, with the best-performing ones hitting the 3-4 word range. Try to choose your words carefully, and add as much description as possible within that limited space. If you’ve already found the perfect title, and it is a little short (1 word) or a little long (6-8 words), don’t worry—a little variation isn’t a bad thing.

Multi-Part Titles Yield More Interest

Players tend to prefer titles with multiple parts. The likely reason is that doing so allows for more information to be conveyed within a small space. Using the multi-part title to evoke additional emotions or description is a solid plan.  

Keep It Unique and Interesting

Titles including non-dictionary words are much more likely to perform better, so having something unique about your title can give it an edge among a list of average titles.

Sequels and Franchises Perform Better

Basing your game on a previous work gives it a better shot at being successful. This likely stems from the familiarity that players have with the original medium, but is also good news for indie devs who would like to turn their singular game into a series.

Further Research for Data Enthusiasts

Interested in how to take this to the next level? Here are two ways to expand the analysis done here for even more in-depth results.

Break Down the IP Subsets

We talked a little about the percentage of games that refer to already existent intellectual properties, but this subset can provide interesting data of its own. How many refer to previous games? Movies? Books? Another interesting line of research to follow would be to compare how multiple titles within a series perform. For example, are fourth games as good as third games?

What About the Worst Games?

We compared the top 10% of games to the entire dataset, but what about the bottom 10%? Segmenting this part of the data could lead to interesting new finds, especially when it comes to naming decisions to avoid.

Wrapping Up

The trends revealed can give you a leg up when it comes to naming your game. If you’re interested in doing a more in-depth version of this study, have questions about our findings, or would like to add to the discussion, leave a comment below!

Creating a VR Game in Unity

$
0
0
What You'll Be Creating

In this tutorial, I will show you how to create a virtual reality game using Unity 3D. Virtual reality games are popular, fun, and can take your game development skills to another level, so let's dive in!

Download Unity

If you haven't already, let's download the latest version of Unity. It is free for personal and hobby use. Unity allows you to create upload your game to many different platforms, including iOS, Android, Xbox, and Linux. 

Adding the VR plugins

Google VR SDK

In order to create a VR game for your chosen platform, we will need to download a couple of plugins. For the purpose of this tutorial, I will show you how to upload to the Android platform. To upload to iOS, you will need to download Xcode

Now let's download the Google VR SDK plugin for Unity. As of this tutorial, it is on version 1.110. You can find it on GitHub. Unzip and extract all the files into a new folder. This will help you keep your files organized.

In addition, if you don't already have it, you may need the Java SE Development Kit. Follow the instructions on the Oracle website.

Note: You may also need to download the Android SDK.

Let's Create a Project

Open up Unity to create a new project. It will ask if you would like to download an asset. Let's download the Environment Package. 

Once your project is open, go to Assets > Import Package > Custom Package > ImportGoogle VR SDK for Unity Import. 

We need to prepare our project for the VR platform. We will need to tell Unity we are building for Android and make the scene VR enabled. First, go to File > Build and choose Android. It would also be a good time to choose Landscape Left. Then click Switch Platform at the bottom and close the window. 

Enable VR

Time to enable the VR settings. If you try to play the game before doing the above, you will receive errors. Go to Edit > Project Settings > Player, and then on the right-hand side under XR Settings, click Virtual Reality Supported.

Add SDK

Don't forget to choose an SDK. For this tutorial, choose Cardboard (as seen above).

Our Environment

GVR Demo scene

Initially, we will be using the GVR Demo scene (shown above). Open up your assets in the Project tab and go to Scenes > GVRDemo. Once the file opens, we will be changing the environment. We will delete the following objects in the Hierarchy: 

  1. DemoSceneManager
  2. DemoInputManager
  3. CubeRoom
  4. Cube
  5. Floor Canvas

For now, we will keep everything else intact. Let's briefly discuss why, as explained by the developers at GoogleSDK. 

  1. GvrControllerVisual provides visual feedback for the daydream controller.
  2. GvrEditorEmulator provides mouse-controlled head tracking emulation in the Unity editor.
  3. GVR Controller gives the player keyboard input.

Let's start our own environment. Save your scene and go to GameObject to add a terrain. In Projects, let's choose a grass surface and drag it onto the scene. To add some substance, let's add some hills. In the Hierarchy under Terrain, let's choose the button with the hill and the arrow pointing upwards. Now choose a brush. It's good to alternate to make your environment look real. If your hills are too pointy, use the smooth button as shown below. 

Tip: Make sure your Terrain does not have Gravity chosen, or it will fly away!

The Unity asset store is a great resource for developers, and you can find it right in your project under Assets. I've downloaded two buildings. You can find them under the Free filter in the Asset Store as "Abandoned Buildings"

Opening the Asset Store

Tip: You can always drag an asset straight into the Hierarchy.

Let's Get Moving

Since not all VR headsets come with a controller, we will need to add an Autowalk code to have the user walk on its own. A movement will happen when you look at an object. 

Once you are happy with your environment, hit Play, and you should be able to look around the world by holding the Alt button. To make our VR character move, we will need to add a script and change some settings on the Player in the Hierarchy

Add Component to Player

First things first: choose Player in the Hierarchy. Let's Add a Component Capsule Collider and a RigidBody. We also need to freeze the X, Y, and ZRotation of the Rigidbody (as shown above).

Now it's time to add our script to the Player. I have attached the script to this tutorial under attached files. Save the file in your Unity folder, and then click and drag it into the Project. Now Add a Component > New Script. Type Autowalk and the script should show up. You may need to save your project and refresh the scene.

Once you add the script, it will give you an option to configure it. We will need to add a Speed of 2 and check Walk When Triggered (see below).

Walk when Triggered

Test Your Game

Time to test your game on your phone. Go to File > Build Settings > Android > Build & Run. You will need to type an identifier (people usually use com.nameofyourgame). As discussed before, you will need to have the Android SDK, which is free to use. 

Save your build and transfer to your phone using a USB cord. Once the game starts, you may need to hit Settings > Cardboard if it looks off.

Unity has an active economy. There are many other products that help you build out your project. The nature of the platform also makes it a great option from which you can better your skills. Whatever the case, you can see what we have available in the Envato Market.

Tip: You need USB debugging to build for Android. If you have an Android phone, navigate to Settings and then About Phone, and tap Build Numberseven times. You will get a new button for developers.

Isometric Depth Sorting for Moving Platforms

$
0
0
Final product image
What You'll Be Creating

Depth sorting can be explained in simple terms as a way of figuring out which element is nearer to the camera and which is farther away, thereby determining the order in which they need to be arranged in order to convey the right depth in the scene.

In this tutorial, we will dig deeper into depth sorting for isometric levels as we try to add moving platforms. This is not a beginner tutorial on isometric theory and is not about the code. The focus is to understand the logic and theory rather than to dissect the code. The tool of choice for the tutorial is Unity, and hence depth sorting essentially is changing the sortingOrder of the sprites involved. For other frameworks, it may be a changing of the z order or the sequence of drawing order.

In order to get started on isometric theory, please refer to this tutorial series. The code and scene structure follow my previous isometric tutorial. Please refer to these if you find the tutorial hard to follow as I will be focusing only on logic in this tutorial.

1. Levels Without Movement

If your isometric level does not have any moving elements or just has a few characters walking over the level, the depth sorting is straightforward. In such cases, the characters occupying the isometric tiles would be smaller than the tiles themselves and can easily just use the same drawing order/depth as the tile they occupy. 

Let's refer to such motionless levels as static levels. There are a few ways in which such levels can be drawn so that the right depth is conveyed. Typically, the level data will be a two-dimensional array where the rows and columns will correspond to the rows and columns of the level. 

Consider the following isometric level with just two rows and seven columns.

Isometric level with 2 rows and numbered z order

The numbers on the tiles indicate their sortingOrder or depth or z order, i.e. the order in which they need to be drawn. In this method, we are drawing all the columns in the first row, starting with the first column with a sortingOrder of 1. 

Once all columns are drawn in the first row, the nearest column to the camera has a sortingOrder of 7, and we proceed to the next row. So any element in the second row will have a higher sortingOrder than any element of the first row. 

This is exactly how the tiles need to be arranged to convey the correct depth as a sprite with a higher sortingOrder will get overlaid over any other sprites with lower sortingOrder.

As for the code, this is just a matter of looping through the rows and columns of the level array and assigning sortingOrder sequentially in an increasing order. It would not break, even if we swap rows and columns, as can be seen in the image below.

Isometric level with 2 columns and numbered z order

Here we draw a complete column first before moving to the next row. The depth perception stays intact. So the logic for a static level is to draw either a complete row or complete column and then proceed to the next while assigning sortingOrder sequentially in an increasing order.

Adding Height

If we consider the level as a building, we are currently drawing the ground floor. If we need to add a new floor to our building, all we need to do is to wait till we draw the whole ground floor first and follow the same method for the next floor. 

For proper depth, we waited till the full row was complete before we moved to the next row, and similarly we wait till all the rows are complete before we move to the next floor. So for a level with only a single row and two floors, it would look like the image below.

Isometric level with 2 floors and numbered z order

Essentially, any tile on the higher floor will have a higher sortingOrder than any tile on the lower floor. As for the code for adding higher floors, we just need to offset the y value of the screen coordinates for the tile, depending on which floor it occupies.

The floorHeight value indicates the perceived height of the isometric block tile image, whereas floorLevel indicates which floor the tile occupies.

2. Moving Tiles on the X Axis

Depth sorting on a static isometric level was not complicated, right? Moving on, let us decide to follow the row first method, where we assign sortingOrder to the first row completely and then proceed to the next. Let's consider our first moving tile or platform which moves on a single axis, the x axis. 

When I say that the motion is on the x axis, you need to realize that we are talking about the cartesian coordinate system and not the isometric coordinate system. Let's consider a level with only a ground floor of three rows and seven columns. Let's also consider that the second row only has a single tile, which is our moving tile. The level will look like the image below.

level with 3 rows and single tile moving in x axis

The dark tile is our moving tile, and the sortingOrder it would get assigned will be 8 as the first row has 7 tiles. If the tile moves on the cartesian x axis then it will move along the trench between the two rows. At all of the positions it may occupy along that path, the tiles in row 1 will have a lesser sortingOrder

Similarly, all the tiles in row 2 will have a higher sortingOrder, irrespective of the position of the dark tile along said path. So as we follow a row first method of assigning sortingOrder, we do not need to do anything for motion on the x axis. Now, that was easy.

3. Moving Tiles on the Y Axis

Problems start to arise when we start considering the y axis. Let's consider a level in which our dark tile is moving along a rectangular trench, as shown below. You can see the same in the MovingSortingProblem Unity scene in the source.

showing depth issues while moving in y axis

Using our row first approach, we can provide a sortingOrder for our moving tile based on the row it currently occupies. When the tile is between two rows, it would get assigned a sortingOrder based on the row it is moving from. In that case, it cannot follow the sequential sortingOrder in the row into which it is moving. This essentially breaks our depth sorting approach.

Sorting in Blocks

In order to solve this, we need to divide our level into different blocks, among which one is the problem block, which breaks under our row first approach, and the rest are blocks which can follow the row first approach without breaking. Consider the image below for a better understanding.

level divided into blocks of which one is the problem block

The 2x2 tile block represented by the blue area is our problem block. All the other blocks can still follow the row first approach. Please do not be confused by the image as it shows a level which is already properly sorted using our block approach. The blue block consists of the two column tiles in the rows between which our dark tile is currently moving and the tiles immediately to the left of them. 

In order to solve the depth issue for the problem block, we can use the column first approach for this block alone. So for the green, pink, and yellow blocks, we use row first, and for the blue block, we use the column first approach. 

Notice that we still need to sequentially assign the sortingOrder. First the green block, then the pink block to the left, then the blue block, now comes the pink block to the right, and finally the yellow block. We break the order only to switch to the column first approach while at the blue block.

Alternatively, we can also consider the 2x2 block to the right of the moving tile column. (The interesting thing is, you do not even need to switch approaches as breaking into blocks itself has already solved our problem in this case.) The solution can be seen in action in the BlockSort scene.

depth issues solved using blocks

This translates to code as below.

4. Moving Tiles on the Z Axis

A motion in the z axis is a fake motion on an isometric level. It essentially is just motion on the screen y axis. For a single-floor isometric level, there is nothing more to do in order to add motion on the z axis if you have already done the block sorting method described above. You can see this in action in the SingleLayerWave Unity scene, where I have added an additional wave motion on the z axis along with the lateral trench movement.

Z Movement on Levels With Multiple Floors

Adding an additional floor to your level is just a matter of offsetting the screen y coordinate, as explained before. If the tile does not move on the z axis then there is no need to do anything special for depth sorting. We can block sort the ground floor with motion and then apply row first sorting to each successive floor. You can see this in action in the BlockSortWithHeight Unity scene.

level with multiple floors and lateral motion

A very similar depth problem arises when the tile starts moving between floors. It can only satisfy the sequential order of one floor using our approach and would break the depth sorting of the other floor. We need to extend or modify our block sorting to three dimensions to deal with this depth problem with floors.

The problem essentially will be just the two floors between which the tile is currently moving. For all other floors, we can stick to our current sorting approach. Special needs apply to only these two floors, among which we can first determine the lower floor as below where tileZOffset is the amount of motion on the z axis for our moving tile.

This means that lower and lower+1 are the floors which need a special approach. The trick is to assign sortingOrder for both these floors together, as shown in the code below. This fixes the sequence so that the depth issues are sorted out.

Essentially, we are considering two floors as a single floor and doing a block sort on that single floor. Check out the code and action in the scene BlockSortWithHeightMovement. With this approach, our tile is now free to move on any of the two axes without breaking the depth of the scene, as shown below.

level with tile moving along all 3 axes

Conclusion

The idea of this tutorial was to clarify the logic of the depth sorting approaches, and I hope you have fairly understood this. It is evident that we are considering comparatively simple levels with only one moving tile. 

There are no slopes either as including slopes would have made this a much longer tutorial. But once you have understood the sorting logic, then you can try to extend the two-dimensional slope logic to the isometric view.

Unity has an active economy. There are many other products that help you build out your project. The nature of the platform also makes it a great option from which you can better your skills. Whatever the case, you can see what we have available in the Envato Market.

Pick Up Some Free Assets for Your Next Video Project

$
0
0

Video is coming soon to Envato Elements, and to give you a taste of what's to come, we're giving away some free video files to use on your next project. 

Free video files from Envato Elements

What's on Offer?

Here are some more details of what you can download from the pre-launch page:

  • eight Adobe After Effects to help you with everything from making an explainer video to creating a cool ink-blotch title effect or a glossy logo sting
  • four backgrounds to use in your videos, whether you're into hipster shapes, abstract neon, or seamless bananas
  • four multipurpose stock images that you could use to illustrate a variety of nature or business videos

What's the Catch?

There is no catch. All you have to do is type in your email address and start downloading. 

And don't worry—you won't be bombarded with lots of sales emails afterwards. You'll just be among the first to hear when the full range of video templates is available on Envato Elements.

How Can I Use the Files?

You're free to use these files to create any end result you want, including for commercial projects, but you can only use them once. More details on the license page.

What Happens Next?

Right now, Envato Elements offers unlimited downloads from a huge library of almost half a million fonts, graphic templates, Photoshop add-ons, photos and more, all for a single low monthly price.

Envato Elements homepage

Soon you'll be able to download from a wide selection of video files as well, but the subscription price will remain the same. So yep, that just means the deal is getting better and better.

Can I Win Cash Prizes Too?

Funny you should ask. As a matter of fact, yes you can. In addition to giving away free files, we're also giving away cash prizes to the people who make the coolest things with them. More details at the bottom of that free video files page. So head over there and start downloading today!

Solving Player Frustration: Techniques for Random Number Generation

$
0
0

If you strike up a conversation with an RPG fan, it won’t take long to hear a rant about randomized results and loot—and how frustrating they can be. Many gamers have made this irritation known, and while some developers have been creating innovative solutions, many are still forcing us through infuriating tests of perseverance.

There’s a better way. By altering how we as developers utilize random numbers and their generators, we are able to create engaging experiences that push for that “perfect” amount of difficulty without pushing players over the edge. But before we get into that, let’s go over some basics of Random Number Generators (or RNGs for short).

The Random Number Generator and Its Use

Random numbers are all around us, being used to add variation to our software. In general, the major uses of RNGs are to represent chaotic events, show volatility, or behave as an artificial limiter.

You likely interact with random numbers, or the results of their actions, every day. They’re used in scientific trials, video games, animations, art, and nearly every application on your computer. For example, an RNG is likely implemented in the basic animations on your phone.

Now that we’ve talked about what an RNG is, let’s take a look at its implementation and how it can improve our games.

The Standard Random Number Generator

Almost every programming language uses a Standard RNG in basic functions. It works by returning a random value between two numbers. Standard RNGs can be implemented in dozens of different ways across different systems, but they all have generally the same effect: return a randomized number where each value in the range has the same chance of being returned.

For games, these are commonly used to simulate rolling dice. Ideally, they should only be used in situations where each result is desired to occur an equal number of times.

If you want to experiment with rarity or different rates of randomization, this next method is more suitable for you.

Weighted Random Numbers and Rarity Slotting

This type of RNG is the basis for any RPG with item rarity. Specifically, when you need a randomized result but want some to occur with less frequency than others. In most probability classes, this is commonly represented with a bag of marbles. With weighted RNGs, your bag might have three blue marbles and one red one. Since we only want one marble, we’ll either get a red one or a blue one, but it’s much more likely for it to be blue.

Why would weighted randomization be important? Let’s use SimCity’s in-game events as an example. If each event was selected using non-weighted methods, then the potential for each event to occur is statistically the same. That makes it just as likely for you to get a proposal for a new casino as to experience an in-game earthquake. By adding weighting, we can ensure that these events happen in a proportional amount that preserves gameplay.

Its Forms and Uses

Grouping of the Same Items

In many computer science courses or books, this method is often referred to as a ‘bag’. The name is pretty on the nose, using classes or objects to create a virtual representation of a literal bag. 

It works basically like this: there is a container that objects can be placed into where they are stored, a function for placing an object into the ‘bag’, and a function for randomly selecting an item from the ‘bag’. To refer back to our marble example, this means that you would treat your bag as containing one blue marble, one blue marble, one blue marble, and one red marble.

Utilizing this method of randomization, we can roughly determine the rate at which an outcome occurs to help homogenize each player’s experience. If we were to simplify results on a scale from ‘Very Bad’ to ‘Very Good’, we’ve now made it much more viable that a player will experience an unnecessary string of unwanted results (such as receiving the ‘Very Bad’ result 20 times in a row). 

However, it is still statistically possible to receive a series of bad results, just increasingly less so. We’ll take a look at a method that goes slightly further to reduce unwanted results shortly.

Here’s a quick pseudocode example of what a bag class might look like:

Rarity Slotting Implementation

Similar to the grouping implementation from before, rarity slotting is a method of standardization to determine rates (typically to make the process of game design and player reward easier to maintain). 

Instead of individually determining the rate of every item in a game, you’ll create a representative rarity—where the rate of a ‘Common’ might represent a 20 in X chance of a certain outcome, whereas ‘Rare’ might represent a 1 in X chance.

This method doesn’t alter much in the actual function of the bag itself, but rather can be used to increase efficiency on the end of the developer, allowing an exponentially large number of items to be quickly assigned a statistical chance. 

In addition, rarity slotting is useful in shaping the perception of a player, by easily allowing them to understand how often an event might occur without eliminating their immersion through number crunching.

Here’s a simple example of how we might add rarity slotting to our bag:

Variable Rate Random Numbers

We’ve now talked about some of the most common ways to deal with randomization in games, so let’s delve into a more advanced one. The concept of using variable rates starts similarly to the bag from before: we have a set number of outcomes, and we know how often we want them to occur. The difference with this implementation is that we want to adjust the potential for outcomes as they happen.

Why would we want to do this? Take, for example, games with a collectable aspect. If you have ten possible outcomes for the item you receive, with nine being “common” and one being “rare”, then your chances are pretty straightforward: 90% of the time, a player will get the common, and 10% of the time they’ll get the rare. The issue comes when we take multiple draws into account.

Let’s look at your chances of drawing a series of common results:

  • On your first draw, there’s a 90% chance of drawing a common.
  • At two draws, there’s an 81% chance of having drawn all commons.
  • At 10 draws, there’s still a 35% chance of all commons.
  • At 20 draws, there’s a 12% chance of all commons.

While the initial ratio of 9:1 seemed to be an ideal rate at first, it only ended up representing the average result, and left 1 in 10 players spending twice as long as intended to get that rare. Furthermore, 4% of players would spend three times as long to get the rare, and an unlucky 1.5% would spend four times as long.

How Variable Rates Solve This Issue

The solution is implementing a rarity range on our objects. You do so by defining both a maximum and minimum rarity for each object (or rarity slot, if you’d like to combine it with the previous example). For example, let’s give our common item a minimum rarity value of 1, with a maximum of 9. The rare will have a minimum and maximum value of 1.

Now, with the scenario from before, we’ll have ten items, and nine of them are one instance of a common, while one of them is a rare. On the first draw, there is a 90% chance of getting the common. With variable rates now, after that common is drawn, we’re going to lower its rarity value by 1.

This makes our next draw have a total of nine items, eight of which are common, giving an 89% chance of drawing a common. After each common result, the rarity of that item drops, making it more likely to pull the rare until we cap out with two items in the bag, one common and one rare.

Whereas before there was a 35% chance of drawing 10 commons in a row, now there is only a 5% chance. For the outlier results, such as drawing 20 commons in a row, the chances are now reduced to 0.5%, and even further down the line. This creates a more consistent outcome for our players, and prevents those edge cases where a player repeatedly has a bad result.

Building a Variable Rate Class

The most basic implementation of variable rate would be to remove an item from the bag, rather than just returning it, like this:

While such a simple version brings with itself a few issues (such as the bag eventually reaching a state of standard randomization), it represents the minor changes that can help to stabilize the results of randomization.

Expansions on the Idea

While this covers the basic idea of variable rates, there are still quite a few things to consider for your own implementations:

  • Removing items from the bag helps to create consistent results, but eventually returns to the issues of standard randomization. How could we shape functions to allow both increases and decreases of items to prevent this?

  • What happens when we are dealing with thousands or millions of items? Utilizing a bag filled with bags could be a solution for this. For example, creating a bag for each rarity (all of the common items in one bag, rares in another) and placing each of those into slots within a large bag can provide a wide number of new possibilities for manipulation.

The Case for Less Tedious Random Numbers

Many games are still using standard random number generation to create difficulty. By doing so, a system is created where half of player experiences fall on either side of the intended. If left unchecked, this creates the potential for edge cases of repeat bad experiences to happen at an unintended amount.

By limiting the ranges of how far the results can stray, a more cohesive user experience is ensured, letting a larger number of players enjoy your game without ongoing tedium.

Wrapping Up

Random number generation is a staple of good game design. Make sure that you’re double-checking your statistics and implementing the best kind of generation for each scenario to enhance the player experience.

Do you love another method that I didn’t cover? Have questions about random number generation in your own game’s design? Leave me a comment below, and I’ll do my best to get back to you.

Code Optimizations for Game Development: Basic Structures and Mindsets

$
0
0

For many starting indie devs, code optimization becomes almost a second thought. It gets passed over in favor of engines or frameworks, or can be considered a more ‘advanced’ technique out of their reach. However, there are optimization methods that can utilized in more basic ways, allowing your code to operate more efficiently and on more systems. Let’s take a look at some basic code optimization to get you started.

Optimizing for Players and Sanity

It isn’t uncommon for indie developers to emulate the optimization methods of larger companies. It’s not necessarily a bad thing, but striving to optimize your game past the point of useful returns is a good way to drive yourself mad. A smart tactic to keep track of how effective your optimizations are is to segment out your target demographic and look at the types of specifications their machines have. Benchmarking your game against the computers and consoles that your potential players are using will help to keep a balance between optimization and sanity.

Basic Code Optimizations

All that aside, there are quite a few optimizations that can almost always be used to help your game perform better. Most of these are system agnostic (and some engines and frameworks already take them into account), so I’ll include some pseudocode examples to get you off on the right foot. Let’s take a look.

Minimizing Off-Screen Object Impact

Often handled by engines, and sometimes even GPUs themselves, minimizing the amount of processing power going into off-screen objects is extremely important. For your own builds, it’s a good idea to start separating your objects into two “layers” essentially—the first being its graphical representation, and the second being its data and functions (such as its location). When an object is off-screen, we no longer need to spend the resources rendering it, and instead we should opt for tracking. Tracking things, like location and state, with variables reduces the necessary resources to only a fraction of the initial cost.

For games with a large number of objects, or objects that are data-heavy, it may even be useful to take it a step further by creating separate update routines, setting one to update while the object is onscreen and the other for off-screen. Setting up a more advanced separation in this way can save the system from having to execute a number of animations, algorithms, and other updates that may be unnecessary when the object is hidden.

Here’s a pseudocode example of an object class using flags and location constraints:

Although this example is simplified, it allows us to poll whether the object will even show up before drawing it, letting us run a fairly simplified function instead of a full draw call. To separate functions besides graphical calls, it may be necessary to utilize an additional buffer—for example, a function that would include anything a player may be able to see shortly, rather than what they are just currently able to see.

Separating From Frame Updates

Depending on the engine or framework that you are using, you may commonly have objects updating on every frame, or “tick”. Doing so can tax a processor pretty quickly, so to ease that burden we’ll want to reduce calls on every frame whenever possible.

The first thing we’ll want to separate is function rendering. These calls are typically resource intensive, so integrating a call that can tell us when an object’s visual properties have changed can reduce rendering drastically.

To take it a step further, we can utilize a temporary screen for our objects. By having the objects directly draw to this temporary container, we can ensure that they are only being drawn when necessary.

Similar to the first optimization mentioned above, the starting iteration of our code introduces simple polling:

During every frame now, rather than performing a number of functions, we can see whether it is even necessary. While this implementation is also simple, it can already start to show huge gains in your game’s efficiency, especially when it comes to static items and slow-updating objects like a HUD.

To take this further in your own game, breaking the flag down into multiple, smaller components may be useful for segmenting functionality. For example, you could have flags for a data change and a graphical change occur separately.

Live Calculations vs. Look Up Values

This is an optimization that’s been in use since the early days of gaming systems. Determining the trade-offs between live calculations and value lookups can help to reduce processing times drastically. A well-known use in the history of gaming is storing the values of trigonometry functions in tables since, in most cases, it was more efficient to store a large table and retrieve from it rather than doing the calculations on the fly and putting additional pressure on the CPU.

In modern computing, we rarely need to make the choice between storing results and running an algorithm. However, there are still situations when doing so can reduce the resources being used, allowing for the inclusion of other features without overloading a system.

An easy way to begin implementing this is to identify commonly occurring calculations, or pieces of calculations, within your game: the larger the calculation, the better. Performing recurring bits of algorithms a single time and storing it can often save sizable amounts of processing power. Even isolating these parts into specific game loops can help to optimize performance.

As an example, in many top-down shooters there are often large groups of enemies performing the same behaviors. If there are 20 enemies, each moving along an arc, rather than calculating each movement individually it’s more efficient to store the results of the algorithm instead. Doing so allows it to be modified based on each enemy's starting position.

To determine if this method is useful for your game, try using benchmarking to compare the difference in resources used between live calculation and data storing.

Utilization of CPU Idleness

While this plays more into the utilization of dormant resources, with careful thought for your objects and algorithms, we can stack tasks in a way that pushes the efficiency of our code.

To begin using sensitivity to idleness in your own software, first you’ll have to separate which tasks within your game are not time-critical or can be calculated before they are needed. The first area to look for code that falls into this category is functionality that is strictly related to the game’s atmosphere. Weather systems that don’t interact with geography, background visual effects, and background audio can all fit into idle computation easily.

Beyond items that are strictly atmospheric, guaranteed calculations are another type of computation that can be placed into idle spaces. Artificial intelligence calculations that are going to occur regardless of player interaction (whether because they don’t take the player into account, or they are unlikely to require player interaction as of yet) can be made more efficient, as can calculated movements, such as scripted events.

Creating a system that utilizes idleness does even more than allowing for higher efficiency—it can be used for scaling “eye candy”. For example, on a low-end rig, maybe a player just experiences a vanilla version of the gameplay. If our system is detecting idle frames, however, we can use it to add additional particles, graphic events, and other atmospheric tweaks to give the game a little more panache.

To implement this, use the functionality available in your favorite engine, framework, or language to gauge how much of the CPU is being used. Set flags within your code that make it easy to check how much “extra” processing power is available, and then set up your sub-systems to look at this flag and behave accordingly.

Chaining Optimizations Together

By combining these methods, it’s possible to make your code significantly more efficient. With that efficiency comes the ability to add more features, run on more systems, and ensure a more solid experience for the players.

Do you have any easy to implement code optimizations that you use regularly? Let me know about them!

Create 2D Tree Shapes With Code

$
0
0
Final product image
What You'll Be Creating

Creating organic shapes like trees can be an interesting side project for potential game developers. You can use the same logic to create levels or other complicated logic structures. In this tutorial, we will be creating 2D tree shapes in Unity using two different approaches: Fractal and L-System.

1. Creating 2D With 3D

Although we call these 2D tree shapes, they are essentially 3D mesh objects in Unity. The game object which has the tree script will need to have these 3D mesh components attached in order to create our tree shape. Those components are the MeshRenderer and the MeshFilter, as shown below.

The necessary mesh components

With these components attached, we will be creating a new mesh using the different algorithms for fractals and L-Systems.

Creating a Mesh

A 3D mesh is created using multiple vertices which combine to form faces. To make a single face, we will need a minimum of three vertices. When we connect three vertices in a clockwise sequence, we will get a face which has a normal pointing outwards. The visibility of a face is dependent on the direction of its normal, and hence the sequence in which the vertices are passed in to create a face matters. Please read the official Unity documentation for further details regarding the creation of a mesh.

With the power of mesh creation under our belt, let's proceed to our first method for creating a 2D tree: fractal.

2. Creating a Fractal Tree

A fractal is a shape created by repeating a pattern with varying scales. Theoretically a fractal can be an unending pattern, where the base pattern gets repeated indefinitely while its size gets reduced progressively. When it comes to a tree, the base fractal pattern can be a branch splitting into two branches. This base pattern can be repeated to create the symmetrical tree shape shown below.

Symmetrical fractal tree shape

We will need to stop the repetition after a certain number of iterations, and the result is obviously not a very realistic tree shape. Yet the beauty of this approach—and fractals in general—is that they can be easily created using simple recursive functions. The base pattern drawing method can recursively call itself while reducing the scale until a certain number of iterations are complete.

The Branch

The primary component in a tree shape is a branch. In our approach, we have a Branch class, which has a CreateBranch method as shown below.

A branch essentially is a shape (or a Quad) with four corner vertices: bottomLeft, topLeft, topRight, and bottomRight. The CreateBranch method does the proper positioning of the branch by translating, rotating, and scaling these four vertices based on the shape, position, and rotation of the branch. The tip of the branch is tapered using the widthDecreaseFactor value. The main tree method can call this method while passing in the position and rotation values for that branch.

Fractal Tree

The FractalTreeProper class has a recursive CreateBranch method, which in turn will create the Branch class's CreateBranch constructor method.

Each call to CreateBranch initiates two new calls to itself for its two child branches. For our example, we are using a branching angle of 30 degrees and a value of 8 as the number of branching iterations.

We use the points from these branches to create the necessary vertices, which are then used to create faces for our tree mesh.

The baseVertexPointer value is used to reuse existing vertices so that we avoid creating duplicate vertices, as each branch can have four vertices but only two of those are new ones.

By adding some randomness to the branching angle, we can create asymmetrical variants of our fractal tree as well, which can look more realistic.

Asymmetrical fractal tree

3. Creating an L-System Tree

The second method, the L-system, is an entirely different beast. It is a very complicated system which can be used to create intricately complex organic shapes or to create complex rule sets or string sequences. It stands for Lindenmayer System, the details of which can be found on Wikipedia.

The applications of L-systems include robotics and AI, and we will only be touching the tip of the iceberg while using it for our purposes. With an L-system, it is possible to create very realistic looking tree or shrub shapes manually with precise control or using automation.

L-System tree sample

The Branch component remains the same as in the fractal example, but the way in which we create branches will change.

Dissecting the L-System

L-systems are used to create complicated fractals where the patterns are not easily evident. It becomes humanly impossible to find these repeating patterns visually, but L-systems make it easier to create them programmatically. L-systems consist of a set of alphabets which combine to form a string, along with a set of rules that mutate these strings in a single iteration. Applying these rules over multiple iterations creates a long, complicated string which can act as the basis for creating our tree.

The Alphabets

For our example, we will use this alphabet to create our tree string: F+-[, and ].

The Rules

For our example, we will only need one rule where the alphabet F changes into a sequence of alphabets, say F+[+FF-F-FF]-[-FF+F+F]. On every iteration, we will make this swap while keeping all the other alphabets unchanged.

The Axiom

The axiom, or the starting string, will be F. This essentially means that after the first iteration, the string will become F+[+FF-F-FF]-[-FF+F+F].

We will iterate three times to create a usable tree string as shown below.

Parsing the Tree String

Now that we have the tree string using the L-system, we need to parse it to create our tree. We will look at each character in the tree string and do specific actions based on them as listed below.

  • On finding F, we will create a branch with current parameters of length and rotation.
  • On finding +, we will add to the current rotation value.
  • On finding -, we will subtract from the current rotation value.
  • On finding [, we will store the current position, length, and rotation value.
  • On finding ], we will restore the above values from the stored state.

We use an angle value of 25 degrees for branch rotation for our example. The CreateTree method in the LSystemTree class does the parsing. For storing and restoring states, we will be using a LevelState class which stores the necessary values along with a BranchState struct.

The variable levelStates stores a list of LevelState instances, where a level can be considered as a branching point. As each such branching point can have multiple branches or just one branch, we store those branches in a list logicBranches holding multiple BranchState instances. The savedStatesQueue tracks the storing and restoring of different LevelStates. Once we have the logical structure for our tree in place, we can use the levelStates list to create visual branches and create the tree mesh.

The GetClosestVextexIndices method is used to find common vertices to avoid duplicates while creating the mesh.

By varying the rules slightly, we can get drastically different tree structures, as shown in the image below.

L system tree variants using slightly different rules

It is possible to manually create the tree string for designing a specific kind of tree, although this can be a very tedious task.

Conclusion

Playing with L-systems can be fun, and it could result in very unpredictable results as well. Try changing the rules or adding more rules to create other complicated shapes. The next logical thing to do would be to try and extend this to 3D space by replacing these 2D Quads with 3D cylinders for branches and adding the Z dimension for branching.

If you are serious about creating 2D trees, I would suggest that you look into space colonization algorithms as the next step.


How to Create a Low Poly Sword in 3DS Max: Part 1

$
0
0
Final product image
What You'll Be Creating

Follow this tutorial step-by-step to create a low poly sword model that you can use in video games, graphic design and illustration projects whilst learning 3D Studio Max quickly. 

Some of the skills you'll learn in this tutorial include creating basic 3D shapes, modelling techniques and preparing topology for texturing.

In this, the first part of the two-part tutorial, I'll show you how to:

  • Model the handle of the sword
  • Model the hand Guard of the sword
  • Model the blade of the sword

1. How to Create the Handle of the Sword

Step 1

Use the Orthographic View for this tutorial. To change views click on the Middle Mouse Button anywhere on the viewport or the small button on the top left of the screen. 

Select the Orthographic View

Step 2

Spawn a Cylinder into the scene by selecting Create > Standard Primitives > Cylinder.

Spawn a Cylinder into the scene

Step 3

In the Cylinder Parameters enter the following:

  • Radius: 15m
  • Height: 90m
  • Height Segments: 3
  • Cap Segments: 1
  • Sides: 6
Adjust the Cylinder parameters

Step 4

Make the new object an Editable Poly by right clicking on the cylinder and selecting Convert to Editable Poly.

Convert the shape into an Editable Poly

Step 5

Duplicate the cylinder by selecting the Move Tool and then holding the Shift Key on the keyboard to drag a duplicate object in the Y axis out of the existing one.

You can also use Right-Click > Clone to duplicate an object. Ensure that you select Copy for Clone Options.

Duplicate the Cylinder

Step 6

Use the Polygon Selection Tool to select all the top polygons of the cloned cylinder (you can do this by holding the Shift Key on your keyboard). Once all but the bottom polygons have been selected, delete them by pressing the Delete Key on the keyboard.

Use the Polygon Selection Tool to remove unwanted polygons

Step 7

Use the Scale Tool to shorten the cloned cylinder.

Scale the shape down

Step 8

Use the Scale Tool to increase the width of the cloned Cylinder and then place it on top of the first cylinder.

Increase the width of the shape

Step 9

Use the Border Selection Tool or the Edge Selection Tool to select all the top edges of the cylinder. Then click on the Cap Button to fill the empty space.

Cap the empty space

Step 10

Use the Cut Tool to create an edge running down the center of the cylinder.

Create a new edge

Step 11

Duplicate the top cylinder and move it to the bottom of the handle.

Duplicate the top cylinder

Step 12

Go to Modeling > Swift Loop. Use Swift Loop to create a new ring around the duplicate cylinder object.

Use Swift Loop

Step 13

Select the new edges and use the Scale Tool to expand the inner ring outwards.

Adjust the shape of the cylinder

Step 14

Duplicate the new shape and use the Rotation Tool to rotate the object 90 degrees. Then use the Move Tool to position the object directly underneath the handle.

Rotate the shape

Step 15

Enure that all the objects are centralised by checking the other views (front, right, left, top and bottom). 

Use the Move Tool or input a value at the bottom (x, y or z) to adjust the objects.

Centralise all the shapes

 Step 16

Select the top cylinder object and duplicate it again. Move the new duplicate cylinder to the bottom of the handle.

Duplicate the top cylinder

Step 17

Use the Vertex Selection Tool to select the middle vertices of the handle. Once the middle vertices have been selected and are highlighted red, use the Scale Tool to move the vertices inwards, towards the middle of the handle.

Adjust the shape using the Vertex Selection Tool

Step 18

Go through each object again and adjust them to your liking using the techniques described above. 

The final sword handle model

2. How to Create the Hand Guard of the Sword

Step 1

Follow the same steps as before to create a new cylinder object. Don't worry too much about the height and radius dimensions this time as they can be changed later on. the rest of the parameters should be:

  • Height Segments: 3
  • Cap Segments: 1
  • Sides: 6
Create a new cylinder object

Step 2

Use the Rotation Tool to rotate the new cylinder by 90 degrees. 

Rotate the cylinder by 90 degrees

Step 3

Centre the pivot point to the object by going to the Hierarchy Tab, selecting Affect Pivot Only and then selecting Center to Object.

Change the pivot point of the object

Step 4

Right click the object and select Convert to Editable Poly. 

Convert the object into an editable poly

Step 5

Use the Scale Tool to scale the object to the dimensions appropriately. After that use the Move Tool to move the cylinder to the top and to the centre of the handle.

Use the Scale Tool

Step 6

Duplicate the bottom shape and use the Move Tool to place it in the centre of the top cylinder.

Duplicate the bottom shape

Step 7

With the new shape still selected, double click on the object colour box to change the colour to blue. This will help you organise the different parts of the sword.

Choose a colour

Step 8

Ensure that both sword hilt shapes are the same colour before moving on to the next step.

Colour the new shape

Step 9

Turn the view port so that you are viewing the sword from the side. Use the Scale Tool  and expand the new shape in the Y Axis.

Adjust the shape in the Y Axis

Step 10

Adjust the hand guard shape so that both shapes are roughly the same height.

Adjust the shapes

Step 11

Isolate the top cylinder and remove the vertical edges. Then create a single edge running down the centre of the shape. To do this select all the horizontal edges around the cylinder and select Edit Edges > Connect.

Delete and create edges

Step 12

Select the faces on the left and right side of the shape and use the Scale Tool to scale them down.

Using the scale tool on the sides of the object

3. How to Create Hand Guard Horns

Step 1

Duplicate the horizontal hand guard shape by using the Move Tool and holding down the Shift Key on the keyboard. Under Clone Options ensure that you select Copy.

Duplicate the hand guard

Step 2

Use the Selection Tool and select one half of the shape. Use the Delete Key on the keyboard to remove half of the shape.

Delete half of the shape

Step 3

Use the Border Selection Tool to select the edges of the shape and then use Edit Borders > Cap to fill the empty space.

Cap the empty space

Step 4

Use Modelling > Swift Loop to create two extra edges to the shape.

Create edges with Swift Loop

Step 5

Use the Polygon Selection Tool to select the right side of the shape. Then use the Scale Tool to scale the side down a little bit.

Adjust the shape

Step 6

Using the Vertex Selection Tool, select the middle vertices and use the Scale Tool to scale it down a little bit.

Adjust the vertices

Step 7

Repeat the same technique for the left side of the shape.

Adjust the tip of the horn

Step 8

With the left vertices still selected, use the move tool to move them up to create a horn like shape.

Adjusting the shape of the horn

Step 9

With the vertices still selected use Edit Vertices > Weld to weld all of them together to create the tip of the horn. Increase the weld threshold if needed.

Welding vertices

Step 10

Select the Symmetry Modifier and mirror the horn in the Z Axis.

Using the Symmetry Modifier

4. How to Create the Blade

Step 1

Spawn a Box into the scene by selecting Create > Standard Primitives > Box

In the Box Parameters enter the following:

  • Length: 10m
  • Width: 85m
  • Height: 230m
  • Length Segs: 1
  • Width Segs: 4
  • Height Segs: 1
Spawn a box into the scene

Step 2

Delete half of the box by using the Vertex Selection Tool and removing the right side.

Delete half of the box

Step 3

Create a the new edges at the top of the box by going to Edit Geometry > Cut. Move the four vertices on the top left of the box towards the right slightly. 

Adjust the vertices

Step 4

Weld the vertices on the left side of the box by selecting the two connecting edges and using Weld. Increase the Weld Threshold if needed.

Weld the vertices to create the edge of the sword

Step 5

Use the same techniques to weld the tip of the sword.

Weld the vertices to create the tip of the sword

Step 6

Return to the front view on your view port and create a sharp point for the tip of the sword by welding the top vertices together. 

To do this, go to Edit Vertices > Target Weld and connect them to the centre.

Weld the vertices to create the sword point

Step 7

Use the Move Tool to move the vertices to create the desired shape of the sword blade.

Continue to adjust the vertices

Step 8

Use the Edge Selection Tool to remove any unwanted edges on the blade.

Delete the edge

Step 9

Use Edit Geometry > Cut to create a new edge for the tip of the blade.

Create an edge

Step 10

Use the same technique to create a small edge at the bottom right of the blade.

Use the Cut Tool

Step 11

Use the Scale Tool to scale the size of the blade so that it suits the size of the handle.

Use the Scale Tool

Step 12

Using the Symmetry Modifier, create the right side of the blade by mirroring it in the Z Axis.

Use the Symmetry Modifier

Step 13

Select the bottom edges of the sword and use Edit Borders > Extrude to create some new shapes at the bottom of the blade. Then use the Scale Tool to scale them all down.

Extrude the polygons

Step 14

With the edges still selected, use the Extrude Tool again to create the bottom part of the blade.

Create the bottom part of the blade

Step 15

With the blade now complete, you can combine all the different parts of the sword together to complete the low poly sword. 

From here you can also organise all the different objects into groups using the Scene Explorer by creating new layers or using Edit Geometry > Attach

The final sword model

Coming Next...

Low Poly Sword

And with that, the Low Poly 3D Sword is complete. Feel free to share your own creations below. In the second part of the the tutorial series, I'll show you how to:

  • Unwrap the UVs
  • Create a UV Map
  • Create a Texture Map in Photoshop

Creating a Unity Game With PlayMaker

$
0
0
What You'll Be Creating

In this article, I will show you how to make a game object move in five minutes or less using the PlayMaker add-on for Unity, with no code. 

Download Unity

If you haven't already, head over to the Unity website and download the latest version of Unity. Unity is a free, user-friendly game engine that allows developers and studios to create 3D games for Android, iOS, Windows, and over 20 other platforms.

About PlayMaker

playMaker

What exactly is PlayMaker? PlayMaker is a paid add-on for Unity that allows you to create games without having to code. Created by Hutong Games, PlayMaker uses functional state machines (FSM) to add physics, animation, interactive objects and scene changes easily. Their developers have already created the scripts for you, which can significantly cut your game development time in half. As of writing this tutorial, the current price is $65.00, with over 370 five-star reviews.

Downloading PlayMaker

Once you have Unity, create a new 3D project. I made a simple scene with a terrain and a sphere. In the main viewport, under the menu toolbar, you will find the Asset Store tab. Type PlayMaker into your search box. Follow the instructions to place your purchase. You may need to use the link in your confirmation email orimportit directly through Unity. You may find that it takes you back to the asset store, but don't worry—click Add to Cart and it should give you the download option. 

Download the file and unzip it into a folder you can easily find. Now let's import a custom packageby going to Assets > Custom Package and opening your unzipped PlayMaker file.

Import Custom Package
Import playMaker

After you'veimported the package, choose Install PlayMaker. This will add the PlayMaker option in your menu bar.

Add the playMaker option to the menu bar

Game Objects

Every FSM needs to be attached to an object. In this case, our sphere will be the object we are looking to control. Later, we will need to specify our game object once an action is created. For now, let's confirm our sphere has a rigid body. In addition, let's freeze the X and Y position of our spherein the Inspector window.

The PlayMaker Editor

Go to the PlayMaker tab on your top menu bar and click PlayMaker editor. This will open the below window. Click and drag the tab to place it next to your Game tab on the bottom.

Install playMaker Editor

On the right of the editor window, you will see four tabs:

  1. FSM
  2. State
  3. Events
  4. Variables
FSM tabs

This is where you will choose the options and parameters for your state. Along with changing the name, you can add in your own description, which comes in handy when you have large projects. For example, this state will move the ball left. 

To add a state machine to an object, choose your object in the Hierarchy. Head over to the Editor window and right click to add an FSM. This begins the state machine, and this will be state one. 

Second, we need to create a System Event (what happens after user interaction). This is what will set off the state, for example button clicked or mouse overFor this project, we will choose mouse over. 

Let's create our next state and name it Ball Moves. You will immediately see a red exclamation point; this is because once you create a state, you will have to define a transition. To define a transition from one state to the other, right-click and choose Transition Target. There you will see the name of the second state you created. You will now see an arrow connecting your two states.

Transition Target

It's time to add physics to our object. The way we do this is by activating the Action Browser. There are numerous actions you can choose for your object, which is pretty cool. 

Action Browser

Feel free to look around at all of the commands you can use in your project. For every action, we will need to set up parameters.  

Adding Movement

Adding Force

In order to make our sphere move, we will need to give it force and velocity through the Action Browser. First, make sure the proper state is chosen. To search for an action, type it in the search box. Let's search for add force. Under the State tab to the right, change the Y variable to 100.

Adding Velocity

Now let's add velocity by repeating the steps above. Change the Y variable to 50.

Hit play and voila! Your sphere should move towards the camera. There are almost an unlimited amount of actions you can perform simply with PlayMaker once you understand the interface.

Conclusion

In my opinion, PlayMaker is a great addition to Unity. Even if you do have coding experience, it can make it that much easier to create interactive, fully animated games in half the time. 

Unity has an active economy. There are many other products that help you build out your project. The nature of the platform also makes it a great option from which you can better your skills. Whatever the case, you can see what we have available in the Envato Market.

If you are a beginner, once you learn the interface you can vastly improve your learning curve. PlayMaker also has a very active community, where you can find questions and answers from users. 

How to Make Your Action Game More Engaging With Reload Mechanics

$
0
0

Action games with weapons in them often utilize some form of reloading mechanic, which is a wonderful built-in game design element. It adds a lot of immediate choice for the player, it makes any encounter much more interesting, and it's easily accepted as an "authentic" mechanic.

After you have expended some of your ammunition, you need to reload. You can do so at any time, but you are then vulnerable during the process. Do you do it immediately? Or do you keep what you have left so that you can defend yourself, even if that's trickier with less ammunition?

In this article, we'll take a look at how various games use this mechanic to their advantage to make an experience more engaging and fun.

Simulated in Great Detail

Seen in: Receiver

Instead of just pressing one button to do an entire reloading cycle, Receiver goes many steps further.

Receiver
Receiver

These are the controls:

Receiver
Receiver

Every step during the reload process is a different button. You need to solve this puzzle in the correct order, all while chaos is breaking out around you!

Then there is another type of weapon in the game, which uses completely different buttons!

This turns reloading a weapon into the puzzle it would actually be in similar situations, especially when under stress and with limited mental attention available.

As a result, shooting a gun in Receiver is a tense affair, and it's much more engaging than just pressing a few buttons.

No Player Input at All

Seen in: Kane & Lynch

The Kane & Lynch games sidestep the reloading issue completely and don't even give the player a choice.

Kane  Lynch
Kane & Lynch

When someone runs out of ammunition, they reload by themselves. When the bullet count is low and they haven't fired for a while, they do it automatically too.

This allows the players to concentrate more on what is happening in the game itself.

Losing Unspent Ammunition

Seen in: Firearms, Tactical Ops

Some games go very far in encouraging players to conserve their reloads. In Firearms and Tactical Ops (mods for Half-Life and Unreal Tournament), for example, your remaining ammunition is not counted in bullets, but in full magazines.

Firearms a Mod for Half Life 1
Firearms, a Mod for Half-Life 1

When you reload, your unspent bullets are not magically restocked between these magazines, but outright lost.

Sometimes these games will keep the halfway-to-empty magazines and you can restock them, but even so, it does encourage more economical use of your reload actions.

Using the Empty Magazine 

Seen in: Metal Gear Solid 2, Metal Gear Solid V

Metal Gear Solid 2: Sons of Liberty introduced a wonderful, fun gameplay element.

Whenever you reload a weapon, your character gains an "empty mag". This cannot be used in any other reloading procedures, but rather can be thrown to make noise and distract guards, which no other item in the game can.

Metal Gear Solid 2 VR Missions
Metal Gear Solid 2 VR Missions

This effectively creates a fun gameplay idea out of the fact that there might be empty magazines around and implements it nicely into the sneaking game. Other characters in-game use the same action by accidentally "dropping" them.

This showed up again in the following Metal Gear Solid titles. Metal Gear Solid V: The Phantom Pain used a different approach by having the player immediately have access to "endless" empty magazines, which was still fun and affected the gameplay, but was less tied into the actual reload mechanic.

Show Bullet Count In-Game

Seen in: Metro 2033, Call of Cthulu

Foregoing a classic "on top" GUI to show bullets in-game is a great way to help immerse the player in the world.

Weapon-Display in Metro 2033
Weapon-Display in Metro 2033

Understanding the ammunition status on different parts of different weapons will take the players a few moments more, which will force them to behave more carefully and not hammer the reload button at any possible moment.

Games With No Reloads Possible

Seen in: Unreal Tournament

Sometimes a game doesn't need reload mechanics! The Unreal Tournament series has done very well without them.

Unreal Tournament 3
Unreal Tournament 3

The fact that these games are set in a sci-fi universe helps with that, as there isn't the expectation of real weapon mechanics.

No Reload and Limited Ammunition

Seen in: Oni, Mirror's Edge

Some games don't actually allow you to reload a weapon. These are games where using a gun is actively discouraged and only a small part of the game, like in Mirror's Edge.

Mirrors Edge
Mirror's Edge

This incentivises the player to grab a weapon from an enemy, use it just for a moment, and then dispose of it immediately when it becomes useless.

It makes for a different kind of action game, where elements outside of shooting (like sneaking and running) are the main focus.

Throwable Empty Weapons

Seen in: Borderlands 2

Similar to some games having non-reloadable weapons, Borderlands has a similar gag.

Weapons of the in-game manufacturer Tediore cannot be reloaded. They look it too, with no replaceable parts, and a cheap, boxy design.

Throwing a Weapon in Borderlands 2
Throwing a Weapon in Borderlands 2

What instead happens when you run out of ammunition is that the character throws away the weapon, which explodes, effectively turning into a small grenade. Rocket Launchers turn into missiles themselves! Afterwards, a brand new (albeit cheap) gun is beamed into your hands, fully loaded.

According to Lead Writer Anthony Burch, this came out of the idea of throwing used magazines at enemies. Developed further, this created a unique and fun gameplay mechanic.

Overheating Guns

Seen in: Halo, Spec Ops: The Line

Overheating is an interesting element as it forces the player to think differently.

Ammunition is less of an issue, but after a few shots the weapon heats up too much, and the player has to wait for it to cool down.

Overheating Plasma-Gun in Halo Reach
Overheating Plasma Gun in Halo Reach

This will make gameplay viable where a lot of shots can be fired, but only in short pulses, and it's a very useful way to limit the usage of stationary, usually very powerful weapons.

Really Long Reload Times

Seen in: Battlegrounds 2

The Half-Life mod Battlegrounds is set during the American Civil War, and the most used items in it are period-era muskets.

Reloading a Musket in Battlegounds 2
Reloading a Musket in Battlegrounds 2

Unlike games set in more modern times (where the reload button is more easily mashed), these take eight seconds to reload, which makes shooting and reloading a tactical decision.

This also has a nice effect on gameplay, as players tend to be more careful about when to shoot and naturally form shooting rows to keep up the ability to defend against attackers.

Conclusion

There is a wide variety of engaging gameplay options available to facilitate gun reloading in games. These are easily accepted as "authentic", and can be much more interesting than just pressing a single button.

Envato Elements Now Offers Video!

$
0
0

Welcome to video on Envato Elements!

If you work with video, your life just got a little easier. Instead of having to create everything from scratch or chase around the web looking for stock footage, motion graphics and After Effects templates, you can now access more than 60,000 top-quality video items, all in one place.

Read all about it on the Envato Blog, check out our related articles and courses, or go and check out the stock video and video templates for yourself!

Related Content

Which Digital Game Distribution Platform Is Right for My Game?

$
0
0

There are a lot of digital storefronts available, each with their own unique benefits. Some work well with certain types of games and engines, while others might not.

Knowing which one you are ultimately publishing to will make development easier, as special features of that platform can already be considered and integrated into the design from the very start.

We'll take a look at most of these and see what their properties are.

Due to the nature and the number of stores available, we won't be able to cover all of them, but rather will look at the most popular ones for smaller developers and what types of platforms are available. We will also forego VR-exclusive platforms, as these are pretty self-explanatory when making a VR game.

Ready? Let's go!

Steam

Types: Windows Standalone, Mac Standalone, Linux Standalone, VR, Films

Barriers to Entry: US$100 (or local equivalent)

Steam
Steam

This is the big one, and it has a de facto monopoly on desktop-game sales.

After the discontinuation of Steam Greenlight, publishing on Steam has become very straightforward, with only a one-time US$100 fee necessary per title published. This fee can be recouped once a game has earned over $1,000, which can be a lot for minor titles though.

The open gates have led to an inflation of games on the platform, which sadly means that publishing a game on Steam no longer automatically guarantees success.

Having a game on Steam allows you to integrate with Steam Achievements, which will be displayed in the launcher. Games can also be integrated into the Steam Trading Card System, a metagame about collecting and trading "cards" that are given out while playing a game.

The Steam API can also be used to facilitate multiplayer, although this is an advanced feature and should be part of development from the beginning, if considered.

Early-access publishing is also possible, and games can receive integrated mod support through the Steam Workshop.

When you make a desktop game, it should be on Steam. It is relatively simple to set up, and there are practically no downsides.

Kongregate & Newgrounds

Types: Flash, Unity WebGL

Barriers to Entry: None

Newgrounds
Newgrounds

Kongregate bills itself as the "YouTube of games" and wants to make publishing as straightforward as possible. It allows Flash apps as well as Unity builds. Newgrounds is one of the oldest Flash portals and helped popularize the format.

Interfacing with the Kongregate highscore system will display a highscore on the site and will track different users. Implementing highscores and giving Kongregate web exclusivity increases the revenue share up to 50%. There is no payout limit, and funds can be requested at any time.

Some games have Kongregate-integrated achievements. These cannot be created directly, but can only be offered by an admin who finds a game worthy of these.

Risks: There seems to be no easy way to shut down or unpublish a title on Kongregate except to upload a defunct version.

If you are making a free Flash game, it might as well go on here and earn you extra revenue. It is also possible to put up a demo for a larger product that is sold on a larger platform, such as Steam or iTunes.

Itch.io

Types: Flash, Unity, Windows Standalone, Mac Standalone, Android Standalone

Barriers to Entry: None

Itchio
Itch.io

Itch.io has a wide range of platforms. Everything that can be uploaded can be offered, and things that can be played via a browser plugin can already be played there. It also offers an optional Steam-like installer.

Payment can occur via a fixed price, donation, or a pay-what-you-want scheme. Early-access publishing is also possible.

Since its inception, itch.io has become a mainstay for indies and even a social network of sorts, with people receiving streams of updates to their favourite early-access games.

I highly recommend checking out Itch.io and having a presence there.

GamersGate & Green Man Gaming

Types: Windows Standalone

Barriers to Entry: Only established games of a certain size

GamersGate
GamersGate

GamersGate and Green Man Gaming have been around for a long time and have established themselves as solid storefronts

The games on sale are highly curated, though, and only established companies and games of a certain scope and quality and accepted, which means smaller ventures should focus on other platforms.

Nintendo Game Store

Types: Wii U, Switch

Barriers to Entry: Nintendo Approval

The WiiU Store
The Wii U Store

In the last years, Nintendo has taken great steps to reduce entry barriers to the Wii U Store, so smaller development studios of just a few people can apply and create games for it too.

Paladin Studios' Momonga - A Pinball Adventure (which I had a small part in developing) was created by roughly six people, first for mobile.

Momonga - A Pinball Adventure Paladin Studios 2013
Momonga - A Pinball Adventure (Paladin Studios, 2013)

This makes the Nintendo Console stores a feasible late target for publishing.

It helps to have already established yourself with one or two solid titles before applying, as they only accept "good" titles in their store. Once accepted, developers can access a special development console, on which they can develop their game.

As with all TV-played games, it would need to be adapted to work on screens and played with the specific hardware.

In development, this should be a long-term goal, which gets easier to accomplish the longer your game-making operation exists.

iTunes

Types: iOS Apps (iPhone, iPad, iPod Touch, iWatch)

Barriers to Entry: US$100 yearly fee (or local equivalent), Mac Computer

iTunes accessed from an iPad
iTunes, accessed from an iPad Pro

The iTunes Store can be accessed by all iPhones and serves apps for that platform exclusively.

One important step in development is that it has to be developed on a Mac. While most Mac and iOS software is created on a Mac to begin with, other tools (Unity, Kotlin, GameMaker) can be created on other computers and then deployed to Macs/iOS, but they still require the last step to be done on an Apple device. Before getting access to the store, you also have to pay a US$100 yearly fee.

Before an app (or update) is published, it needs to pass Apple approval, a process that can take several days. During certain times of year (Halloween, Christmas), when a lot of apps offer holiday-specific updates, the approval process can take up to two weeks.

Games can also be integrated with Game Center, which offers achievement tracking and other features across games.

Risks: The yearly fee has to be paid, otherwise games get pulled off the store. Also, game clones are rampant and can often appear more prominently than the original title.

If you have the hardware, can afford the entry fee, and your game can deploy to iOS, it makes a lot of sense to create an iOS version.

Mac Desktop Store

Types: Mac Standalone Apps

Barriers to Entry: US$25 yearly fee (or local equivalent), Mac Computer

The Mac Desktop Store
The Mac Desktop Store

The Mac App Store is bundled with every Mac and offers direct downloads onto computers. Only Mac Standalones are sold.

The yearly developer fee is only US$25, unlike the iTunes mobile store.

Risks: The yearly fee has to be paid, otherwise games get pulled off the store.

Google Play Store

Types: Android Apps

Barriers to Entry: US$25 one-time fee (or local equivalent)

The Google Play App Store
The Google Play App Store

The Google Play Store is the official storefront for Android devices.

To begin publishing, a US$25 one-time entry fee has to be paid. After that, apps can be uploaded fairly quickly and will appear on the store within hours.

Risks: Requires a Gmail account. When an app gets shut down for whatever reason (e.g. a collaborator has been accused of copyright infringement),  the entire Gmail account is shut down, including access to all other Google and YouTube accounts and logins of that user. I highly recommend creating a separate account to publish on. Also, game clones are rampant and can often appear more prominently than the original title.

Amazon App Store

Types: Android Apps

The Amazon App Store
The Amazon App Store

Android Apps can also be sold on Amazon, where they can reach Kindle devices. You can check out this tutorial on how to set things up!

Risks: Amazon occasionally offers apps for free. During these times, the download numbers increase immensely, but the creators do not get reimbursed for these.

Direct Payment (various)

Types: Any Content, App & Game (except iOS)

Fastspring
FastSpring

A lot of services allow you to sell games and apps directly to users. This usually gives you most of the revenue, as compared to the usual ~30% of the sale price a portal takes.

FastSpring, PayPal and the Humble Widget are popular solutions, and they take less than 10% of the sale price. SendOwl charges a monthly subscription, so this makes more sense at a later date, once sales have been established.

The downside is that you'll have to set up everything before the sale (website, ads) and everything after the sale (delivery of files, support) by yourself.

Android-Based Microconsoles & Smart TVs

Types: Adapted Android Apps

Barriers to Entry: Specific Hardware, various certification processes

The Razer Forge Microconsole Controller and Storefront
The Razer Forge Microconsole, Controller and Storefront

There are several microconsoles (Razer Forge, GameStick, Amazon Fire) and Smart TVs which can run Android apps on TV sets.

A lot of Smart TVs also run on Samsung Tizen, which is a Linux-based operating system, to which a lot of engines (GameMaker, Cocos2d, Unity, etc.) can deploy.

When you create an Android game, these platforms would be an interesting late platform target. Games need to be adapted to work on TVs, though, which you can learn about in this tutorial!

Windows Store & Windows Mobile

The Windows Store can be exclusively accessed by Windows Phones, Surface Tablets, and Windows 10 computers.

The Windows Store on Windows 10
The Windows Store on Windows 10

A lot of engines offer deployment to these (like Unity). The stores themselves provide an entire ecosystem outside of iTunes and Android Stores, but have a comparatively small audience and should be a late development option.

Other Portals

Publisher-Exclusive Portals

Origin
Origin

Origin, Battle.net, and uPlay only publish major titles created by EA, Blizzard, and Ubisoft respectively.

Should you get folded into the mix, your games will appear there.

Defunct Portals

Desura ca 2010
Desura, ca. 2010

Desura, Indievania, and IndieCity used to be pillars of the indie community, but have sadly become defunct in recent years.

New portals such as Itch.io have proven to be worthy successors and continue to allow easy and straightforward publishing.

Conclusion

What does this mean for you, the developer?

It makes sense to focus on one platform first, and then eye other potential targets once your game has been established.

If your game is Flash-based, you can target Flash portals first and then move to desktops via Steam.

If you sell very unconventional games and get a lot of your traffic through your own website, it makes a lot of sense to set up your own direct payment system.

If you are making a mobile game, it makes sense to focus on the mobile portals first. If you are making an Android game, microconsoles become an option. Depending on your development environment, you can then also look into desktop variants!

Snuggle Truck, for example, debuted on Flash platforms. It was later ported to mobile devices, and then desktop computers.

Snuggle Truck Owlchemy Labs 2011
Snuggle Truck (Owlchemy Labs, 2011)

If you are making a desktop game, you have many more options than just Steam, and expanding to Itch.io and the Mac Store could greatly increase your audience.

And making a game that works in a browser, on desktop and on mobile would be tricky, but would offer you a very wider audience to being with! For example, Rymdkapsel manages to be very entertaining on both tablets and desktop computers, and has an easier time finding people to play it.

Rymdkapsel (Grapefrukt, 2013)
Viewing all 728 articles
Browse latest View live