I’m facing a hard question at the moment: What to work on next. It’s always tricky. The AI is sufficient for play-testing but needs proper trials to reveal the most important areas to improve it next. There are many areas I’d like to improve it but for showing the game, AI isn’t the most important. For that, full experience is most important.
Maybe this arena is exhausted? By that I mean a given environment prompts certain ideas, reveals certain failings, etc.
Hmm, no — I still haven’t done what I’d originally intended with the trees — set fire to them and have them fall down! (A nice destructible environment adds to the fun, I feel.)
So, enough wondering for now. Fire time!
So, how to implement spreading? Want lots and efficient. A GameObject per fire centre might kill things. Lowest is a single ParticleSystem (perhaps a “Particle Playground” or “PA Particle Field” one for the turbulence?) Use one-off sphere-cast to detect areas to spread to. Of course we actually want things affected by the fire so this might be ‘too efficient’. Also it would be nice to have parts to burn-out — ideally from exhausting fuel which we’ll need to specify per thing affected. Let’s call YAGNI and do simplest implementation in a new project and test performance. Then bring into SnwScf actual and see how it performs there.
First version simply has a trigger and spawns on anything entering the trigger. This worked but needed limiting to not overlay itself (since new instances generated new OnTriggerEnter() calls). Also, since triggers give a Collider (not a Collision), I needed to ray-cast to find the actual point on the Collider. I used the obvious and cast from own centre to Collider’s Transform centre but then realized the fire would only spread towards the centre of the subject!
Next switched to a random point from cardinal directions above (picture 8 points at cardinal points around point but car down to surface from above).
To make it more organic, I limited it to one of these points and, after listening to more of this episode of Game Developer’s Radio on juiciness where they discuss good randomness, I decided to implement the Grab Bag Random facility Devon talked about. I’ve put the source up since it’s kinda handy if you want this sort of randomness.
This worked but looked OK on the fence I was testing it on but looked like a game of snake on a flat surface!
Needed to switch to all three points! This fills a surface but would look less good on other shapes and doesn’t handle going down.
Switched to a 3D filling pattern — works well!
Or, setting spread range to the radius produces this rather dense result!
And, replacing the sphere with some simple Particle Playground flames
Of course the prefab I quickly pasted in isn’t a good final version but it shows the idea. The final one will need to build incrementally (so the flames don’t seem to suddenly jump) and generally look better (include some dark multiply particles for contrast or ideally use a volumetric shader).
Anyway, that’s it for Sunday.