These last days, I've been working on 2 new features in the game:
- Travelling on the back of a turtle
- Having a cyclic world (well, technically, this is a torus)
I - The Turtle
At some point in the game, the player can travel the whole world without restriction. Of course, this means he can't only swim because it would be waaaaay too slow. So I wanted to create a cool means of travelling... and, thinking about my creation creed "freedom, humour, oneiric", I chose to make him ride a turtle! I first created the 3D model in Blender and the texture in GIMP as usual.
Another texture far from optimized...
But creating a new feature is not that easy. A lot of questions are raised about this turtle:
- How is it controlled?
- How fast should it be? How long would a player travel between islands without being bored? How can I reconcile this with the minimum necessary distance between islands to be sure that I don't clutter memory or slow down the game?
- Can the player use items while being on the turtle back? If yes, which ones?
- Can the player jump? Or crouch? Is it interesting/useless?
- How can the player switch from the turtle riding to swimming?
I didn't answer to all of these questions, but I made a few choices.
I implemented the same kind of controls for the turtle as for the player.
Using the Bo (the melee weapon) seemed kind of useless on the turtle's back. Range weapons, however, can be interesting for water fights. The problem is that shooting from the turtle back at high speed gives the impression that all projectiles are very slow in comparison... It's even possible for the turtle to be faster than an arrow.
So I set up 2 different travelling speeds:
- At low speed, the player can shoot
- At higher speed, no shooting is possible, but the turtle can quickly travel between islands.
The turtle in-game.
In order to give more feedback to the player while travelling on the turtle, I used lots of little tricks:
- Foam and ripples behind the turtle
- Little water splashes
- Random bigger water splashes
- Water trail behind the fins
And for the highest speed
- Wind trails around the turtle
- Shorter camera focal length
- Fish eye effect to accentuate the speed feel
And in both cases, additionnal turtles randomly spawn around to accompany the player for a few seconds. This gives a bit of life to the travel!
Riding turtles!
II - Cyclic world
If the player can go everywhere on his turtle, this raises the question of the world limits. I can simply put some kind of uncrossable wall/mountain/obstacle at the edge of the map, but I don't like this idea. It goes against the freedom feeling I want to give to the player.
So I chose to make a cyclic/tile-able world. The idea is that if the player leaves the map on a side, it re-appears on the other side. Basically, this is a "simple" translation of the player. However, there is a lot of other objects to "teleport" to the other side of the map: particle effects around the turtle, other turtles, all the projectiles that the player can shoot, and of course the camera, which is a bit tricky, because it has a very smooth movement based on previous position and velocity that I must recompute after teleportation.
Another problem is that there is a specific kind of object that I can't translate: trails... because they are dynamically computed in the world space and I can't access the information of vertex position (this is a limitation of Unity, I guess because it is cached in the GPU in some way). So I can't move them, and I can't recreate them on the other side of the map by copying and translating vertex positions.
If I don't teleport the trails, this creates a very visible glitch during teleportation: they suddenly disappear. I finally chose to make them disappear progressively while the player approaches the map border, which is hardly noticeable.
If the player sails exactly on a
border, a new problem appears: I don't want to teleport him on nearly every frame (this can
be a heavy operation depending on the number of objects to teleport). So, I wait for the player to go past X meters beyond the map border before teleporting him to X meter inside the opposite map border. This creates an "hysteresis" behaviour which prevents multiple teleportation calls and drastically improves the frame rate on map edges.
Additionally, instantly teleporting the player and the camera can create a break in the ocean animation. To avoid this behaviour, I had to carefully tune all ocean texture scales to be sure the global period matches the world size, but at the same time I wanted to avoid obvious repetitions... Another compromise to make by playing with prime numbers!
I also had to work on a few other "little" things: adding wave/water sound
while moving the turtle, creating the "horn" sound which is used to
call the turtle (this will be justified in the story), collision tests
with islands, ... I can't talk about everything here!
And here's how it feels at the moment:
You can notice the cyclic world thanks to the basic grass square island. Of course, in the end game, it will be real islands. This is only a technical test.
Finally, riding the turtle is kinda cool! Of course, I should add more objects on the ocean to give it more life (floating barrels, plants, barges, boats, fishes, and other sea animals), but, each time, I'll have to deal with the teleportation problem. I'll also have to carefully position islands far enough from the map edges so that they won't suddenly appear when the player is teleported.
See you next time!
Peace!
Peace!