3D Platformer GameDev Series – Weekly Blog #4: Jump Animation, Fixing Game Logic, and Improving Aesthetics/Controls

Hello everyone! I am now officially one month into the 3D Platformer Udemy course! Today, I will use what I learned last week in implementing idling and running animation states in order to add a jumping animation to our robot player. Along the way, I will fix some of the ‘game logic‘ concerning the player’s jumping ability and speed. Finally, I will setup and improve some of the general game aesthetics and controls. Alrighty, let’s dive right into Unity!

We begin by opening our Player Animator again and adding a new state for “Jumping”. We then assign our built-in robot jumping animation to it, disable exit time, and set an appropriate fixed duration for the animation (similar to what was done for the idling and running states last week):

AssignJumpAnimation(Animator)

Next, we create and assign a boolean parameter called “Grounded” (similar to the way we created the “Speed” float parameter before). To transition from our “Idle” to “Jumping” state, we can trigger this by setting a condition whereby the “Grounded” parameter is false (Note: the same condition applies for our “Running” to “Jumping” transition – which is not depicted below):

State Transition (idle to jumping)

The opposite transition (from “Jumping” to “Idle”) is triggered when “Grounded” is true and the “Speed” is less than 0.1 (Note: the same condition for grounded is true for our “Jumping” to “Running” transition except speed must also be greater than 0.1 – not depicted below):

State Transition (jumping to idle)

In our player controller script, we add a line of code at the bottom that would determine the value of “Grounded” (similar to how we had set and determined the value of “Speed” in the line of code just above it). At this point, we shall also fix a game logic issue whereby the player can jump higher and higher without ever touching the ground. This can be done by using a Unity function called “isGrounded” on our character controller (not to be confused with the “Grounded “parameter in our animator as it is not the same thing!) – which checks to see if the player is on the ground before the jump button can be pressed again:

JumpAnimationScript

A second game logic issue occurs when the player holds down two adjacent directional keys to move diagonally, causing the player to move almost twice as fast! In order to fix this issue, we add a line of code before the movement speed is determined to normalize the player movement speed regardless of the directional input.

Another game logic issue persists when the player walks off the edge of a platform. In this case, the player snaps instantly to the ground below the platform as a result of the speed of the gravity on the player continuing to increase indefinitely (until the jump button is pressed). This can be fixed by resetting the gravity speed to zero whenever the player is on the ground:

NormalizingMovementAndFallingOffEdgeFix

And onto the game aesthetics now! The first thing we can do is to hide the mouse cursor in the game. To do this, we add the following two lines of code in a new Game Manager script:

GameManagerScript (hide mouse)

Finally, we re-assign and add additional controls to enable full game controller compatibility. Of course, a must for any 3D platformer is to be able to rotate the camera – often achieved on the right analog stick:

SetupControllerInputs

Alas, our robot player is complete with most if not all of its game logic issues resolved! And… we can now use an X-box controller to test out the controls!

PlayerControllerAndAnimatorFinal

Next week, I will learn how to create a “killzone” (an area which would “kill” our player upon entering it). This would set the stage for us to implement a respawn system for our robot player. Thanks for reading and stay tuned!

– Taklon

GameDev Blog #3: Basic Items, Equipment, and Inventory System

After implementing walk and run movement for our player, I started creating some basic interactable objects which would also show up as items in a player inventory system. In addition, I made a few simple pieces of equippable items such as clothes.

So far, I am trying my best to spend a minimal amount of time working on the aesthetics and UI for 2D/3D models and sprites since they can be re-designed and/or their level of detail can be raised later. Instead, the bulk of my time has been used towards primarily completing all the functional systems (e.g.- player movement, inventory, combat, etc..), and of course, a lot of time is spent constantly debugging and trying to get things to import and work properly in both Blender and Unity.

Interactable Environment Object

blueherbBlue herbs can be picked up in the game scene/environment. Once picked up, they appear in the player inventory. Later, they can be used as a consumable item to restore  some of the player’s health.

itempickupandinventorysystem

Equippable Items/Equipment

vagabondshirtA simple, default equippable shirt for the player.

vagabondpants
A simple, default equippable pair of pants for the player.

equippingclothesEquipment will appear on the left-side in the inventory once equipped (this will be implemented at a later point). For the next update, I will add a basic weapon and design an enemy to prepare for the combat system.

GameDev Blog #2: Player Walk/Run Cycle

Hello everyone! So at the moment, I am actually playing catch-up a bit with the blog. That is, I am actually further ahead in my game’s development than I am in blogging about the latest updates on it. Actually, it’s kind of strange, but it seems to be keeping me motivated this way… Anyway, I’m sure it won’t take long before I keep everyone truly informed on the latest updates here.

After assembling the environment and coding the camera and player movement last time, I figured there was a need to implement something more – shall we say – aesthetically pleasing for the player movement next. I mean, I’m sure nobody ever gets tired of staring at a great-looking T-pose…. right?! /s

Player Walk Cycle

playerwalkanimation

Player Run Cycle

playerrunanimation

Implementing Player Walk and Run Cycles by animation blending in Unity

playerwalkruningame

You may also have noticed a new blue-looking plant-like object in the game demo above. While most environmental assets in the game will be non-interactable, some will be interactable such as the blue herb in this case. For such interactable objects, the player shall be able to pick them up. And of course, a player inventory is necessary to display any objects that were picked up. More on this for the next blog post though!

GameDev Blog #1: Basic Game Assets and Player Movement

A few weeks ago, I blogged about transitioning to Blender 2.80, familiarizing myself with the Unity UI, and learning some basics of programming in C#. Today, I am starting a “GameDev Blog” series and as with many game development blogs, the aim of mine is to allow me to share my progress for a game that I am attempting to create and develop. And rather than explaining how I accomplish things (as in my previous blog series on “The Complete Blender Creator Course”), this development blog will contain primarily screenshots with a minimal amount of text showcasing what has been done instead.

The Game Concept

Keep. It. Simple. I tell myself because this is my first game, a point-and-click RPG I am developing entirely on my own, it would be remiss of me if I come up with complex ideas off the bat that are or will become too difficult to hatch out. So I have decided that the idea of my game would simply be for the player to collect materials, fight monsters, collect loot, and craft items while the main objective is to defeat the endgame boss, a giant flying beetle. All of this would take place inside a forest.

Environment

backgroundandforeground
For the environment, a plane is used as the “background” while a curve is used to construct the “foreground” – the latter in which the player can move and interact in.

tree1 tree2
Some trees (non-interactable) for the background environment (will be remade later).

flowers leafplant
Some plants (non-interactable) for the foreground environment (will be remade later).

Player Design

playerdesignBasic player/character modelled and rigged (facial features will be added later).

Assembling the Environment and Coding the Camera and Player Movement

playermovementingame
The background and foreground along with a few of the environment assets were exported from Blender 2.80 into Unity 2019.1.1. A prototype game scene was assembled and the player model was also exported into the scene. Simple player movement control was programmed and the game camera was also coded to track player movement.

Section 7 (Part 4): Learn 3D Modelling – The Complete Blender Creator (Udemy) Course

Yikes… It’s been a long time since I last updated everyone on my progress in The Complete Blender Udemy Course! Although, to be honest, I had hardly opened up Blender since writing my last blog post back in early October 2018. If it is any consolation for myself, I did at least watch the rest of the lecture videos for Section 7, and wow, was there an incredible amount of information to absorb there…

When I began Section 7, I mentioned how ambitious and potentially demanding creating a game asset pack would be. To recall the scope of this project, the instructor had asked us to include at least 10 models/assets and, at that time, I think I exuberated a bit too much confidence and came up with a list of 16 models/assets instead. As a result, I eventually decided to narrow it down to 11:

section 7 - planning your room (final update)

From the above picture, you can see that I decided to exclude the vines, stone steps, barrel, mushroom, and door entrance in the asset pack. This left me with having to just model a pot and a well. Easy enough, right?

First, I chose to model the pot as it less organic compared to most of the other assets and it would be a good example of a non-modular game asset that requires especially good topology. Here, I used a bezier curve to obtain an outline of the pot and then converted the curve into a mesh. Still, even as something as simple as a pot, retopology was needed to reduce the geometry count, particularly around the opening/mouth of the pot:

pot

Next, I chose to model the well as I thought it would give some variation to the asset pack. Furthermore, it gave me an opportunity to dive into a bit of fluid simulation – pardon the pun:

well

To wrap up Section 7, I tweaked a bit of the proportions for some of the assets previously made. And after readjusting the camera, a final render was taken of the room containing all the assets. I hope the render isn’t too dark for some of you to see on your screen; I decided less lighting was necessary to resemble the ambience you would find in an underground laboratory as, after all, that is the theme of the asset pack:

prototype_final (lightingadjusted)Edited Jan. 23/2019: Brightened the image so it should be easier to see on some devices now.

Whoa… We’re almost at the end of the course now! So the next and final remaining section (Section 8), entitled “The Human Head”, is just over the horizon. As a matter of fact, I am feeling quite nervous about it. You see, growing up, drawing humans was the hardest thing ever for me… Don’t laugh, seriously! In any case, I will do my best to learn and I shall also try my best to update the blog frequently in 2019!

– Taklon

Section 7 (Part 3): Learn 3D Modelling – The Complete Blender Creator (Udemy) Course

Alright, time for a quick update (I promise this will be a short read this time)! I think I am now about halfway through finishing all the models for my game asset pack. Circled in green below are what I have completed to date:

Section 7 - Planning Your Room (midpoint update)

If you had read my previous blog post, you will have noticed that since then, I have been working on a bookshelf, table, and chair. From the reference pictures, it seems that most of the wooden assets (with exception to the crate) are made up of the same kind of wood. As a result, I modeled the bookshelf, table, and chair similar to how I modeled the room entrance’s wooden frame: using mirror modifier(s) along with scaled cube(s) as plank(s) for the general shape, subdividing, sculpting, decimating, and texturizing. Last but not least, I re-made the cobblestone floor and am actually quite satisfied with the result.

Bookshelf (Asset #12)

bookshelf

Table & Chair (Assets #7 & #8)

table+chair

Cobblestone Floor (Asset #2; re-made)

cobblestone floor (re-do)

Shoutout and thanks to one of my blog followers, redboarwiiingers, for commenting in my previous blog post and suggesting to embed the stones for the floor. Great suggestion!

Here is what the prototype scene looks like now:

prototype_#6

First thing you will probably notice is that the proportions are completely out to lunch – kind of funny actually if you look hard enough! The door entrance and wall torches should be bigger and everything else could be smaller as well. Next, the lighting could use a bit of work; however, that will be one of the final things to tackle. And while the scene is still relatively low poly (taking only a few hours to render 5000+ samples in full HD), I do want to mention that there is one key step that I have left out in modelling my assets (primarily those that involved sculpting) which is retopology. Retopology is the process of re-creating good mesh topology, usually as a result of it becoming poor during the modeling process. I mentioned about the importance of good mesh topology when modelling the queen piece in the chess set back in Section 4. As an example, it is better for a mesh to consist of just quads and/or triangles; ngons are not ideal! Furthermore, retopology can greatly reduce the poly count without affecting the level of detail – something which is greatly sought-after for game assets in general.

I aim to finish watching the rest of the lecture videos and modeling the rest of my assets by the end of next week. This will leave me with the remainder of October to polish up the entire asset pack. If time permits, I may delve into Unity and see if I can have some of these assets imported from Blender. Stay tuned!

– Taklon

Section 7 (Part 2): Learn 3D Modelling – The Complete Blender Creator (Udemy) Course

Update time! If you have not read my previous blog post, perhaps it is worth checking out first before reading on to understand the work scope for Section 7, Game Asset Pack, in the Blender course I am taking. Recall that I mentioned I will be concentrating on the following assets circled in red:

PlanningYourRoom (focus #1,2,4,6,10)

Most of the assets circled in red are essential and modular meaning that they are necessary and should be able to assemble together like building blocks. This way, when exported to – say a game engine – it will allow the user to quickly construct a room or building of any size with varying levels of lighting aesthetics (i.e. – number and placement of wall torches).

Just as a reminder, I am and have been deviating away from most of the content in the course (I explained why in my previous blog post). In turn, I’m learning that using additional, external resources and tutorials and also experimenting and doing things on your own helps! And now, onto modelling the assets!

Brick Wall (Asset #1; essential + modular)

wall(textured)

For the brick wall (very low-poly, 82 faces), I had initially used a simple plane to map and bake an image texture onto it. I then realized it would be problematic though if the wall was viewed from the side. While it likely would not be viewed from the side since a room is almost always contained entirely by its walls, this was a concern for the room entrance (see Asset #6 below). So, I added a bit more geometry simply by extruding the plane out and then re-mapping the texture. Bear in mind that I do have a high poly version of it with individually-sculpted bricks – ideally used in a rendering of a scene with up-close camera angles/shots rather than a game asset as with this low-poly version.

Cobblestone Floor (Asset #2; essential + modular/tileable)

cobblestone floor

For the cobblestone floor (relatively low-poly, 506 faces), I struggled with this particular asset the most. I had actually re-done it several times and am still thinking of re-doing it differently (I followed pananag’s tutorial for constructing tileable medieval stone floor on YT). This particular asset was tricky for two reasons: 1) individual cobblestones should look round as in the reference picture, 2) it not only needs to be modular/tileable but should also appear seamless when assembled together. For point 1), subdivision surface and/or multiresolution modifiers could easily make the cobblestone appear round, however, this greatly increases the geometry – which for the floor, should be kept low-poly. For point 2), making it tileable without the entire floor looking patterned once assembled together was impossible unless I increased the size of it, but this would make it useless to construct small rooms. Furthermore, since there are two different material types, it was difficult to make it look seamless. Anyone have thoughts/ideas to get around these two issues? I will have my ear to the ground for this – pardon the pun!

Room Entrance (Asset #10; essential + modular)

room+wall entrance

For the room entrance (relatively low-poly, 4343 faces), I started with a simple cube (lol). I scaled the cube by flattening and elongating it. I then sculpted it to resemble a wooden plank (following most of Grant Abbitt’s tutorial for sculpting wood on YT). A second wooden plank was constructed and the two pieces were duplicated and given some variation using proportional editing. All four pieces were then aligned and joined to form the doorframe. I then took the existing brick wall asset (see Asset #1 above) and removed some geometry in the middle to make a doorway. Finally, I joined the wooden doorframe with the wall. Once this high-poly version was completed, a decimate modifier was used to bring down the insanely high poly count.

Wall Torch (Asset #6; essential)

walltorch

For the wall torch (low-poly, 453 faces), I started with a cone for the rigid joint. Two cylinders were used to construct the arms and just simple extrusion and beveling was done to create some of the detail. The internal Blender physics engine in cycles render was lastly used to generate a flame (following Olav3D’s tutorial for creating a quick fire animation on YT). I then added a simple material node setup (glossy BSDF, ColorRamp, and Layer Weight) to generate a chrome-like material for the torch.

Rock (Asset #3)

rock (medium)

For the rock (low-poly, 175 faces), I started off with a metaball, which was immediately converted to a mesh so sculpting could be done on it. Once I had the general shape of the rock as pictured in the reference image, I added a decimate modifier to bring down the high poly count. Using a simple yet ingenious material node setup (following Blender Smoothie’s tutorial on making a rock using built-in textures on YT), a rather realistic look was given to the rock. I won’t show the node setup here as it is massive and you won’t be able to see any of the parameters, but have a look in the linked video if you are interested!

Crate (Asset #4)

crate

For the crate (low-poly, 664 faces), I started off with a cube (of course…). Keeping it entirely a single mesh, I subdivided it several times – just enough to construct the outer housing. I then UV unwrapped and mapped two different textures: one for the inner planks and another for the outer housing. This was the first non-essential asset I had modelled actually (before the rock) in which I didn’t follow any tutorials so I’m pretty proud of how this one turned out. I’m equally excited to do the same with the barrel.

Alas, this is pretty much what I have so far! Here’s a quick prototype scene I put together in a few minutes. This full HD rendering (1024 samples) took approx. 20-25 minutes:

prototype_#2

I will likely be re-doing the cobblestone floor (I think I have some ideas actually…) and continuing to model the rest of the assets (or at least have a general idea to low-detailed versions of them over the next week or so). Hope you enjoyed reading today’s blog post and I look forward to writing the next one as always!

– Taklon