Fire in blender game engine

Hey guys, I am getting tired of seeking help but if you can indulge me. I been throwing the idea of a fantasy role playing game around. For the concept, there needs to be a sorceress throwing a fire ball.

I searched around internet and couldn’t find a decisive answer on this. What’s the general step that would go in to create a fire effect. I seen it done with animated textures, then I saw an old tutorial that uses some type of particle emitter for game engine.

Now, can any of you shed some light on how this is actually done.

Already done in 2013… what search engine do you use ??

Next would be : What style of effect you are up to (convienient for low poly or more realistic)? And maybe of course what game engine derivative…

i actually seen this tutorial but dismissed it at first because the results is not as good as I want it. but upon second look, I may just use this method since it gets the idea across fine.

You can just use any Blender fire tutorial, no need to search for BGE specifically. If it’s something that requires animating timeline, like particle systems, just do so from a script. I’ve heard people struggled with Blender’s particle systems in BGE, but I’m so far have zero problems using them in-game with UPBGE.

It’s always good to say what one has already found instead of telling that one has nothing found :stuck_out_tongue_winking_eye:

Also: in almost all game (engine) one usually do not use realistic fire simulations but some approximation.

And again style from low poly:

…up to going deep down the rabit hole:

( but this may depend on all the other things in the scene… and/or graphics card power…)

1 Like

particles in UPBGE? please make a small demo file!

Do these (fluid) really work in Game?

Just an object with “override logic transform priority” and a normal Blender particle system on it. The only trick, which I’ve seen mentioned many times elsewhere is to move timeline from script. I prefer doing everything with components so this is what I came up with:

import bpy, bge
from collections import OrderedDict

class Timeline(bge.types.KX_PythonComponent):
    args = OrderedDict([
        ("Timeline Framerate", 60)
    ])

    def start(self, args):
        self.framerate = args["Timeline Framerate"]
        self.scene = bpy.data.scenes["Scene"]
        self.current_frame = 0
        self.max_timeline_frame = 1048574

    def update(self):
        self.current_frame = int(bge.logic.getFrameTime() * self.framerate)
        self.scene.frame_set(self.current_frame % self.max_timeline_frame)

And when I need to trigger particles I just manually set their start and end frames like this:

        self.particle_system.frame_start = self.timeline.current_frame
        self.particle_system.frame_end = int(self.timeline.current_frame + duration * bge.logic.getAverageFrameRate())

I’m using upbge-0.43-alpha-windows-x86_64-2024-07-19, never used any other version. Maybe I’m missing something, but it works for me in any mode I tried to run this. Regular, viewport, standalone.

ah yes, these simulations work with timeline.
I on my side never cereated a game using this.
What happens on timeline end or when you reset it?

I’m not very familiar with UBGE’s actual features…
…also the OP didn’t mention yet what “fork”… but maybe about the style !?

In my example, I set timeline length to maximum value of 1048574, which should take ~4.8h at 60 fps. And then there is modulo operator in formula, it basically starts going again from 0 after it reaches timeline end. When you set frame_start and frame_end manually like in the latter code snippet, it doesn’t matter much which current frame is, except there could be a corner case when frame_start is near the end of timeline, and frame_end is something unreachable because timeline is going to reset. I’m yet to handle this corner case, but I’ll postpone it for later since it’s really hard to get into situation like this at the moment. The easy fix that comes to mind though is to track active particle systems and simply reset timeline to 0 prematurely when there are none. This way it would be impossible to ever reach that ~5h mark.

Here is an animated Sprite-Sheet Shader-Node.
With a little script to run it during game.

03_SpriteAnimation_kai.blend (1.5 MB)