To begin this blog post, I will outline a few tweaks given to the sword system.
As stated in my previous post, I found a way to limit this feature only to when the sword hands are present.
This if statement also shows my solution to a few other emerging issues with the system. The collisionDetect bool was created due to the cutting crashing my computer, as too many cuts would occur if the blade stayed in the middle of any object for too long.
With this code, the cutting is reliant on the bool being false. Whenever a cut is made, the bool is set to true, and only made false again when it is no longer making collision with an object. This means it can only make one cut at a time.
The gameObject tag area of the if statement sorts one final issue where the swords were cutting objects they shouldn’t, such as pieces of the hands, or blocks for other mechanics. Having it so it can only cut tagged objects is a simple fix.
One last change was I added this line to solve a problem I was having with cut pieces falling through the floor. This adds a box collider to new pieces so they no longer do this, however it can cause some issues with collisions, as the newly generated box colliders can sometimes be too large. Perhaps I can look into a way to make the colliders more accurate to cut pieces.
So that’s the alteration to the sword out of the way, the next topic of discussion is the development of my scene.
Initially, my scene was very basic, with the UI hand selector, a box to cut, and a wall for eventual climbing. And while my project is primarily a system demo over a full game, Herman gave me some advice to develop my scene.
I started off initially by browsing some of the asset packs I had previously purchased here and there on the Unity asset store, eventually creating a simple scene out of some voxel based buildings and roads that matched the look of the hands.
I also added a skybox to just give the scene a better overall look, but it was definitely an improvement and wasn’t too complicated to draw away from my systems.
Next came the organization of the mechanic areas. I wanted to separate out different areas for each hand to be tested, setting up small obstacles for the player to test out trying to get past. A suggestion from Herman came later to make these zones color-coordinated, to make it even easier for the player to know where to go.
A small thing related to the scene development also relates to the function of the hands. Initially I was having trouble finding a way to code it that only the hands could push the green boxes, trying to use IgnoreCollision functions. However, I learnt that I could achieve the effect I wanted a lot easier using the built-in layer collision matrix in Unity. This system allows you to limit which layers interact with each other.
After all these changes, the scene looked and functioned a lot better.