Creating a smelting furnace

The furnace is the first entity which uses the WorkComponent we’ll create.

It will have an inventory to provide both ore and fuel on the left and a slot for the crafted item on the right.

When it detects that it has fuel in its bottom slot and something it can smelt in the top slot, it consumes one piece of fuel, one piece of ore, and crafts the result into the slot on the right.

After completing this entity, we’ll create an electric furnace that uses your power grid to smelt ore instead of fuel.

But for now, let’s do it the old-fashioned way.

The furnace blueprint

Like anything we can craft and place, we can start with the blueprint.

Create a new scene, FurnaceBlueprint.tscn, with a BlueprintEntity root node named FurnaceBlueprint and a Sprite child. Make sure to put it in /Entities/Blueprints/ so it gets picked up by the Library autoload.

Set the sprite’s Texture to blueprints.svg, set its Region data so it displays the furnace sprite. Then, move the sprite up so its floor is at the origin.

All this should be rote for you by now so I’m breezing through.

I set the Stack Size to 5.

Here’s the furnace’s texture.

And how your scene should look.

The furnace entity

With the item done, we can move to the entity.

Create a new scene, FurnaceEntity.tscn, with a StaticBody2D as a child.

Again, you can probably see the steps coming even before you read them.

Add a Sprite node for the graphics and set its Texture to tileset.svg, turn on Region -> Enabled, and use the TextureRegion bottom panel to set the sprite to the furnace graphics. Raise the sprite so it sits on the floor of the origin.

Add a new CollisionPolygon2D node and create a new polygon, with the back slightly inflated to prevent the player from clipping through because of y-sorting.

Your scene dock should look like this.

We could have it sit there, impassively, as it smelts, but that’s not any fun, is it?

Iron melts at 1500 degrees! That’s red hot.

It’d be nice if the vents could glow as it melts ore, with some sparkles flying out.

Making the furnace glow

I prepared two sprite textures that match the furnace’s side vent and front grill for that.

Create a new Node2D named Vents, and add two sprites, one for the front Vents and one for the side LoadingVent.

We’ll use the Vents node to fade both sprites in sync.

Turn on Region -> Enabled for both sprites, assign the tileset.svg texture to them and set their regions to the appropriate textures.

The vents are the white shapes to the right of the furnace’s texture.

You’ll have to use the pixel or grid snap mode for the front vents instead of Auto Slice. As you can see below, the image slicing algorithm detects separate shapes.

Move the two sprites so they cover the vents, as illustrated below.

To animate fused metal flying out, we can use a Particles2D node positioned in front of the vents.

I won’t dive into Godot’s particle system, as we have a course dedicated to that: Godot VFX Secrets).

The gist of using it involves assigning a new ParticlesMaterial resource to the particle and playing around with the configurations to get something you like.

In my case, I made them be the default squares flying out from the grill and fading away after half a second.

Here are the Particles2D’s properties.

And here is the ParticlesMaterial settings I changed. Mostly the Emission Shape, the Direction and its Spread, and the Initial Velocity combined with some Gravity.

Here’s the final scene tree.

And I placed the particles in front of the main grill.

It doesn’t look like much right now, but it’ll look much nicer with a bit of glow.

The magic comes when we assign HDR colors to our vents and particles using animations.

With Godot’s color picker, you can assign color values greater than 1 using the Raw button (you have to turn off the HSV button first to do so).

You can do that on the Particles2D’s Modulate property.

For the particles, I set them to a bright yellow with a lot of red.

Below, notice that the Raw button is turned on, and I set the red channel to a value of 2. We’ll use that to trigger Godot’s built-in glow effect.

For the Vents node, I set them to a rich, red-orange.

Then, I set the A channel, the alpha, to 0 so both vents are transparent.

To set up the nodes for animation, I disabled Emitting on the Particles2D by default.

To animate the lot, I added an AnimationPlayer and set my animations.

One is “Work”, and all it does is fade in the Vents by animating their Modulate color’s alpha channel from 0 to 1 over one second. At the end of the animation, I turned on Emitting for the particles.

Then there is “Shutdown”, which turns off Emitting on the particles and animates the A channel of the Vents’ modulate to 0, again over one second.

If you play it now, it will look a little orange-ish with yellow squares coming out of it and that’s it.

But if you add a new WorldEnvironment node to the scene and drag default_env.tres into it, things should look a whole lot better.

I configured the environment to use the Mode of Canvas for its background and enabled Glow with its Blend Mode set to Additive.

This takes all the HDR colors, with values greater than 1, and puts them into their own texture, blurs them in a few layers, then adds them back on top of the screen.

The WorldEnvironment gives you access to Godot’s built-in post-processing effects. While most of them are for 3D games, like screen-space reflections or fog, you can use the glow, tone map, and other image adjustments in 2D.

Note that you can only have one WorldEnvironment node per canvas layer, so you want to delete it from the furnace scene and instead go into Simulation.tscn to add a WorldEnvironment there.

All that’s left to complete the scene tree for the furnace is to give it a GUIComponent and a WorkComponent.

In the next lesson, we’ll create the furnace’s GUI, and the one after that, we’ll script the smelting process.