Montag, 6. Februar 2017

Developer Diary 52 - Thinking Out Loud



Ok, so for the last couple of days I couldn't figure out a bunch of problems that I have been mulling over for a week now .... I wrote a long mail to a friend of mine about this, and it seemed to open my eyes to a different solution.

So this post is just going to be a long ramble about code and framerate issues, so that I can get this thought process out of my head and onto a piece of paper. I hope it will lead to a solution or at least some fresh ideas....

I've created a couple of blueprints that spawn the entire game environment and are responsible for the placement of foliage, interactables and trees. But I have the following problems:

- How do I connect the maze spawner with the natural environment? 
The maze spawner needs an even ground for it to work, because if there are hills, the player is able to simply jump over the borders. I could implement a tunnel, or a gate, that leads the player into a new atmosphere.

- What would that tunnel look like?
The front would have to resemble Gothic architecture, made out of black marble and several towers built around it. It would lead into a tunnel, with the exit leading through the Southern Gate of the Maze Blueprint. But where does this tunnel spawn? On top of a hill? That looks shitty as hell. Inside a hill? But the player will collide with the landscape model, and I can't create landscape holes through code at the exact location the tunnel will spawn... Underwater? But then the maze would have to be underwater as well.
But if I clamp the spawn Z coordinate of the gate to a high value (e.g. Z of Landscape + 1000) it will almost always spawn on top of a hill. I can create a large foundation reaching into the ground and the gate itself simply leads to a staircase upwards. After the staircase there is a closed tunnel bridge, with Gothic windows left and right. Once the player leaves the tunnel, he's standing in the center of the maze blueprint. I can even add one of the Wall Cycles to this blueprint, so the tunnel doesn't appear to lead into thin air.
I'll need to create a collision box inside the tunnel bridge, and on End Overlap all former landscapes will be destroyed. But what if the player turns around? .... Maybe he can't turn around .... maybe there is a door, that keeps him from going back, and the collision box appears after the player has passed the door .... that might work ....

Why are my trees and foliage actors not de-spawning properly when they are out of sight?
My foliage blueprint creates hundreds of linetraces by channel straight up into the ground along the Z axis. When one of those linetraces collides with a landscape actor, it saves the trace impact point and spawns a tree actor at this location. The spawn scale varies greatly. But with a varying spawn scale, the visibility collision sphere of each tree actor also varies. Usually it would be easy to solve, by simply setting the spawn scale to 1,1,1, in the foliage spawner, while randomizing mesh scale inside the tree actor. But the tree meshes aren't centered properly in their native files. Which means that as soon as I change the scale, each tree will be off center. The solution in this case would be to manipulate each mesh in 3dsMax and set them up in a way so that they are centered properly again. And as I think about this .... there is probably no way around this .... for some reason I can't stand 3ds Max. I was hoping there would be a different solution .... but now that I see it written down .... damn .....

How can I create, cost effective, spawnable, low poly grass and implement it into the foliage spawner?
First of all I probably should use "Mobile Woodland Grass" Models from the "Realistic Grass" Package in Unreal. It looks great and has a very low vertex and poly count. But the problem is, that if I start spawning them in the same way I did with the trees, I will create massive framerate problems. I want the grass to only spawn around the player. I want it to appear at a range, where the player doesn't see it appearing. And I want it to be destroyed when it's far enough away from the player so he doesn't notice its destruction.
For the grass to disappear I can simply set up a visibility collision sphere around the grass actor. I can randomize the mesh scale slightly, since this mesh is actually centered. The best way to deal with grass is probably to separate it from the tree spawning foliage blueprint. So I guess it would be smart to create a "grass spawner". This grass spawner has to follow the player throughout the game. It would spawn grass all around the player (get player character -> get actor location -> break vector -> x+10000 -> y+10000 -> make vector a.s.o). There would be a "grass counter" to manage the total number of grass models on the ground. All this blueprint does is spawn grass on the ground based on linetrace impact points. They will destroy by themselves through their own visbility sphere.

Why not simply use a culling volume?
For some reason I always experience a massive FPS drop when I implement a culling volume in my world. Of course I could transform each grass actor into an instanced static mesh .... but let's picture a situation in which the player moves East twice, and then suddenly moves West twice again. The previously spawned grass will reappear and be completely out of line with the newly spawned landscape's Z coordinate, because all the culling volume does is "hide" the instanced mesh. And from what I've learned so far, destruction is cheaper than hiding stuff.

How can I create abysses?
I previously created a "Black Death Volume". As soon as the player collides with it, he will be "Game Over" and the player character will disappear. Now the problem remains: How can I create a situation in which the player has to jump from platform to platform in order to survive? If it is possible to spawn landscape actors with the "worldspawner", then it will also be possible to spawn "platforming segments" with it. These platforming segments would probably consist of a landscape mesh with very steep mountains (set world3dscale  -> Mesh -> z = 8). With these mountains a death volume of equal size and a "platform spawner" will be created. The platform spawner will ensure, that the player can actually enter this landscape segment while at the same time randomizing the players route to overcome this landscape segment. Additionally I could tweak the item spawner in a way, so that it will spawn special items only on platforming landscape segments.

How can I deal with the AI without the use of navigation volumes?
In part this problem is already solved, with Obersturmführer and Wehrmachtgefreiter.Their behaviortree is set to "Move Directly Toward" while they are clamped down to the landscapes Z value. And even if they follow the player underwater it mostly looks wicked, to see them wade through an ocean, while still aiming for the player. But there must be a timeframe and a ruleset for how long they will follow a player. Not all enemies can spawn at all locations. The crawling Giant can only appear in the maze, the Worms can only appear in abysses and the Mantas can only appear underwater. If each AI is specifically programmed to only function in its natural habitat, then it is much easier to set up AI without the use of navigation volumes.

Wow.... looks like this blog post was a good idea .... it's much easier to go through all these steps by writing them down .... it's as if my brain doesn't have enough capacity to work through this all at once ....

S.M








Keine Kommentare:

Kommentar veröffentlichen