There are a lot of things that go into creating a realistic environment. We always want our game worlds to feel as if they were real and there were actual physical forces affecting everything around the player. Today we are going to show you what it takes to achieve such a feeling by taking a look at our vegetation and the systems that affect it. This is a larger topic, so we will divide it into smaller pieces. We highly encourage you to check out all the high-resolution versions of the GIFs, as you'll be able to see all the details more clearly!
First of all - the grass. While it might not seem like much, walking around the world filled with tufts of grass certainly beats a simple texture that only tries to imitate it. Our level designers have various models to choose from, but in general, they are divided into categories based on their size. We distinguish between small, medium, large and very large models. The size obviously changes the look and feel of the area the grass is placed in, but the size is relevant also because of the forces that we apply to it - wind, bending, and shockwaves.
Let’s take a look at each of those forces one by one, starting with the wind. Our engine currently allows us to place two kinds of wind forces on the scene - local and global. Local wind only affects objects in a specific radius. An example of such a wind force is a tornado. Here’s an example, where you can clearly see the limit of the tornado’s effect on the grass:
Global wind, on the other hand, affects all the entities on the scene. It is responsible for all the swaying that occurs naturally, without any outside interference. Regardless of the wind type, it is regulated by a whole lot of parameters, which allow us to simulate the flow of air. Without going into much detail, using a whole set of functions we can get a slightly different wind direction and strength in various points of the map. You can see these represented by vectors on the gifs.
Shockwaves come into the picture whenever something explodes (and you know how we feel about explosions). Shockwaves come in two flavors as well. The first one is instant. It applies the force to all objects within a radius of the explosion. The amount of force and the radius depend on the size of the explosion. The other type of shockwave is called physical shockwave. It is a separate effect, and occurs after the instant shockwave takes place. It takes the form of a ring that increases in diameter over time, affecting the grass tufts further away from the center of the explosion.
The bending force bends the vegetation away from the source, which can be any entity that has the BendingComponent in its properties. We apply this component to things like the mech, enemies, and bigger projectiles, such as rockets. The strength of the bending force gets progressively weaker with the distance from the source. The example below shows you the vectors of the bending force and the affected sphere.
Of course, if we applied wind, bending and, shockwaves together at once we would only get a glitchy mess as a result, as they would clash against each other. Instead of that, whenever game logic gets updated, we take a weighted average of all the forces, giving them a different factor of importance. The result of this operation is then applied to the vegetation. Based on this, plants in The Riftbreaker can exist in 3 states:
Idle - no forces other than the wind affect the entity,
Bending - when a bending force is currently being applied by another object
Recovering - the bending force is no longer being applied and the object is returning to the idle state.
Science time!. In order to achieve the effects of the grass swaying in the wind and its springiness, we need to apply some math. We approximate the restoring force by using this function:
The bending effect is, in turn, a vertex shader. It manipulates the vertex of the object and bends it according to a parametric square function. The values of bending and restoring vary between the different models, which gives each of them a unique feel.
We wouldn’t be ourselves if we did not give you the opportunity to set something on fire. That is where the FlammableComponent comes into play. Every entity with that component can be set on fire. We can tweak the probability of the object catching fire if it’s currently being affected by a fire source, such as a flamethrower, as well as the time it will burn once it is set ablaze. Every time the game logic is updated, the information is gathered which objects are currently in the range of open fire. Then, we perform a roll for each of those and if the result is positive, the object will catch fire. Some things are almost impossible to set on fire, while others need just a spark to burst out in flames.
Once the entity is on fire, we give it another set of properties - BurningComponent. The affected piece of vegetation becomes the source of fire itself. With this component, we can control the range to which an object can spread the flames. The bigger the entity, the further it can spread the flames. We also control the burning rate, which determines how often an attempt to spread the fire is performed. Apart from the BurningComponent we also apply the proper particle effects and start dissolving the mesh. What is noteworthy - the spread of fire is affected by the wind!
Here's a link to the compilation of all the GIFs used in this article:
YouTube™ Video: The Riftbreaker - Schmetterling Engine 2.0 Vegetation System Views: 965 Wishlist on STEAM: Store.steampowered.com The Riftbreaker: Riftbreaker.com EXOR Studios: Exorstudios.com The Riftbreaker™ is a base-building,...
That’s all we have for you today! Thanks for reading, and if you have any questions, feedback, or suggestions, let us know in the comments or on our Discord! www.discord.gg/exorstudios!
Other social media: