Devlog 2: Water system 2/3: how the new system works
Hi! Gleb here.
With the possibility to hand-draw arrows, and then convert the image into a json file, the implementation in Unity is just a matter of bug fixing :)
First, I took the generated texture, and the file and added both of them to a 3d plane.
The algorithm is following - during the start of the plane (note that sometimes I can call it “panel” by accident) reads data from the json file, and parases the info - angle and direction for each cell. Then, it also calculates its own angle (the global rotation of the plane), and it has a serialized field for force multiplication. So, with all of these, it creates a matrix of vectors – so for each cell, we have a vector of force, with proper direction (and length).
After that, when a dragger point enters the hitbox of the plane, the plane calculates the local position of the dragger and returns the corresponding vector from the pre-calculated matrix. Sounds easy, but during this, I managed to mess up coordinates, forget to normalise the local position (so 0,0 is in the corner, not the centre), and face some minor problems.
Nevertheless, the arrow-drawing system is working now, check out the GIF!
By the way, I decided to keep the priority system, so with new currents, it’s also possible to have multiple overlapping objects that will work based on the priority they have.
I already dream of the possibility of drawing the arrows right inside the editor. Man, also an ability to run python script by one klick would be SO AWESOME. But unfortunately, it’s just not rational to spend more time in creating tools for development – without a working demo (that will slowly accumulate more and more players), this project will not survive. So, let’s focus on more important things at the moment, and maybe return to improving developer (and modding) tools later.
Static waves
The Second part of improving water is water bumps - the water should not be flat. For now, let’s keep it simple, and make the surface static. Maybe later I could change it, and add real waves, but I already know that it’s very performance-demanding (I would need to optimise it a lot, to keep the game running on old devices).
So, the system I’m using is very simple - I just created a second terrain, and I just deformed it as I wanted. Then, a script calculates the height at the given point, and the boat floats according to this height. For now, we will stop on this solution – editing terrain in Unity is ok, especially compared to other approaches for changing meshes in the editor. In any case, I want to use the new current system for some time, before deciding in which direction I need to improve it.
The rest is to redo the demo level with these new improvements. But, since it is also a good opportunity to improve the beauty of the level (properly paint the terrain), I will show it in the following devlog.
Also, I did some additional fixes or some improvements:
Map is Fixed
Honestly, when doing the map system I tried to do a robust, smart system that uses proper principles of Linear algebra to do a simple action - calculate the position between borders. But, as you may know, this “robust” map broke right before finishing the Jam version. So, I just made the code dummy - instead of complex maths, I just wrote a lot of if statements. Ultimately, the system works as I wanted - you just place cubes in the corners of your map, take a screenshot above with an isometric view, and have your map ready! The perfectionist inside me wants to rewrite the code properly, but I’m following the number one advice for all programmers: “Works? Don’t touch!” (or I think the more English form of it is “Don’t try to fix what is not broken”).
Controller support
I’ve started to add controller support to the game. At this stage, it’s super easy – in addition to a/d and ←/→ I’ve just added LB/RB. So now, you can row while lying on your sofa! It's not a big deal at this stage, but since I’m planning to add the possibility of walking out of your boat, it’s good that I at least started to learn how to play on a controller (just playing RDR2 in the evenings). Also, controllers seem to be super easy to use for coop, but let’s talk about it later.
Backwards rowing
I realised I missed this mechanic, only after testing the jam version for some time. The time has come! Now the double-tap-and-hold action is for back rowing, while “stopping” is changed to triple-tap-and-hold.
Camera stabilisation
In the beginning, I added a simple camera stabilisation. Later it will be switched to proper settings, but before releasing the public demo I want to make sure that less people will feel motion sickness. Will see how it works during playtests.
So, the work continues! The next step is showing the current direction and force by shader and adding elevation to the map (so you will start above sea level).
Stay strong!
Get To the Rapids!
To the Rapids!
A kayak adventure controlled only by two buttons
Status | Released |
Author | GlebThePolarCitizen |
Genre | Simulation, Adventure |
Tags | kayak, rafting, Relaxing, whitewater |
More posts
- Devlog 3: Water system 3/3: visual effects74 days ago
- Devlog 1. Water system 1/3: replacing current currents!93 days ago
- To The Rock!Aug 30, 2024
Leave a comment
Log in with itch.io to leave a comment.