Unity and most modern game engines have a strong base physics system. This base system is great for most games as then you don’t need to license an expensive middleware like the Havok physics engine or code your own.
I bring this up as a lot of junior designers and programmers get scared away from the topic thinking they’re going to need to re-learn years of mathematics.
Physics in games is a deep topic, but unless you are coding a physics engine, you do not heavy math. Your in-game physics will never be 100% scientifically accurate, and that is ok.
When learning game development, especially the gameplay coding side, there’s a bit of a trap. When learning you often end up keeping everything in code, especially documentation, as it’s just faster to get through the learning. When coming from enterprise coding this is also just the norm as the majority of the work is done by coders and any documentation will be right there in code.
The reality of the job of a gameplay programmer is very different though, as you are working with a lot of non-coders. Team members from UI artists, Game Designers, and Level designers are going…
Loading in a sprite (2d image) and actually animating it in-engine is actually pretty straightforward but the first time can be a hassle to learn as it’s many tiny steps.
The steps we’re going to take are:
For the artwork, I’m using the art pack Sunnyside World purchasable on itch…
Prototype boxes and capsules can get us pretty far but eventually, we need some real art assets, animations, and effects. Now while it’s nice to have custom art assets made for the project, if you’re still in the early stages of prototyping sometimes you need to use a model kit and animation kit instead to avoid wasting an artist’s time.
These likely won’t be the final models but for a few dollars or a little google searching for CC0 assets can lead to model packs that look passable for a small game’s final build. …
Game Assets even simple low-poly assets, take hours to produce. So the last thing you want is to create a bunch of assets, only to never use them in the final build.
This can happen easier than you think considering the complexity of the game design. Finding the “fun” takes a while and if we had to create art assets custom-made to get a prototype done we’d be chucking away days of work every attempt.
The smaller the team, the more importance there is on ensuring nothing is going to waste. So to avoid waste, we prototype early and use…
As discussed before timers are everywhere in games. BUT in past articles, I’ve only written about simple timers using delta time in the default Update Loop.
If we look at Unity’s Order of Execution we can see there is something that happens immediately after the update loop called Coroutines. These are extremely powerful once you know what you’re doing with them and they work more intuitively to how we think about timing.
Most people learn quickly how to set an empty Parent object to stash things like Managers and level props. But when spawning objects in Unity such as bullets, and enemies by default it will just spew into your hierarchy making debugging a nightmare.
The simplest way is to set up an empty object as you would with level props or managers, then add a serialized field for a GameObject. Drag and drop to hook up the folder object to the player variable. Then when we Instantiate the new object we assign the folder GameObject to the object’s parent.
Games have so many moving parts from 3d, animation events, and physics. Not to mention all the code we need to communicate between the different parts and objects.
At this level of complexity, we require ways to handle Dynamic Events between two objects; events such as a sword swing connecting with an enemy, or a player walking close enough for a button prompt to appear. We can not hard-code these setups either as we simply don’t “know” when they will occur.
That’s where GetComponent can come in.
Unity3d has a few tutorials out there but one of my favorites is this official 2013 tutorial which is where the above gif is from. While the exact steps are a little different than what I’ve written below the base is still the same. To recreate the door we’d simply re-use the concepts below but just add a breakable force level to the joints.
Joints are great for breakable panels to rope physics, to bosses that can swing wrecking balls of death, to just Ragdolls.
The simple 101 examples of joint usage we’ll be doing are hanging platforms with interactable…