Rainy Day Stacking Gameplay Overhaul + Camera Adjustments!
Rainy Day Devlog #4: Stacking mechanic gameplay overhaul and camera adjustments!
Hello world! Thank you for tuning in on another devlog for my financial literacy casual/educational game, Rainy Day!
So, compared to how the gameplay felt from the prototype I have made and showcased in the last devlog, I've been busy bettering the core stacking mechanic as well as have the camera adjust the player view as their stack gets taller or shorter.
Shoutout to Game Developers Staying Afloat
But before I get into the ins and outs of how I went about doing so I just want to give a shoutout to all the game developers out there with a 9-5. I'm in the same position as many of you with the same dream of doing all of this full time. Keep at it with the early mornings developing before work if that's you or in the later time of the day. It won't happen quick as you probably know but someday it will. Just take the necessary steps. I wish you all happiness and the success you deem success to be.
Stacking Using Unity's Physics Engine
What you're about to see here is straightforward and have taken longer than it should have. The short sessions of development, getting the ball rolling and needing to stop for work probably contributed, but I struggled with the core stacking mechanic. I wanted to achieve a realistic sort of behaviour that players would expect when stacking items while having that game-y epic feel. I ended up doing more than what was needed, trying to manipulate velocity, angular velocity, and inertia of the rigidbodies being stacked when I believed it should. Turns out, I didn't need to put in all that worked though and it really just got me nowhere but just left me lessons which I'm sure will come in useful in the future.
And part of the struggle was because stacked items were somehow rotated on a supposed flat surface (the player) causing the items to slide left and right. So, actually, I even tried adding friction and upping the drag of the objects. Slight friction was part of the solution but the drag as well as everything else I have said resulted in unexpected and undesired behaviour.
Stacks are just not stable in Unity for some reason. Stacking default cubes at a height not even that tall will collapse even with zero force on it and the solution is painfully simple. I just had to ask more out of the Unity physics engine and the steps are:
- Navigate to
Edit
on the top bar and chooseProject Settings
with the dropdown - Then, onto
Physics
on the left hand side of the pop-up window - Have
Enabled Adaptive Force
checked - Most importantly, increment the
Default Solver Iterations
andDefault Solver Velocity Iterations
to a higher value than default for your desired stacking behaviour. The higher the value set the costlier the performance. So, just keep that in mind.
There goes the solution to my problems and my desired stacking behaviour for Rainy Day! I hope this finds the developers who need it.
Camera Adjustment
In terms of the camera view adjustment, I didn't have any major problems. I took the camera's Y position with an offset and based the upward adjustment off of that once the height of the stack is greater than its value. The same goes for the downward camera adjustment except the adjustment is called based off of items that had moved the camera up when it touches the object respawner at the bottom of the player's character.
One thing to take out of this section is that implementing a camera follower/adjuster script provides a smoother look than just simply making it a child object of the gameobject to be followed. For this implementation, I used the Mathf.Lerp
function to smoothly adjust the camera from one position to another.
Next Up
What is likely to be done for the next devlog is the scoring system that will give introduction to the idea of "financial literacy" for this game and with that I suppose a variety of collectible items to be stacked.
Support My Work and Have Your Name in the Game!
If you are ever interested in having your name forever embedded in the startup screen of the game once it is out, consider doing a top donation subscription tier on here while bringing my dream life closer to reality at the same time! Anything helps so even a free subscription here is huge and you will be emailed a link to beta test Rainy Day once it's available.
Thank you again for tuning in!
September Donators
Special thank you shoutout to my website supporters who donated in September!
- Laura Milligan