Slow Rush Studios logo,
    depicting an apprehensive-looking snail rushing forward

Slow Rush Studios

◂  Writing These Updates
News index

Creative Barriers

Contents

Some weeks, it's hard to think of what to build next.

You catch up on email, start a new todo list, watch twenty-two vaguely relevant Youtube videos, fantasize about a total rewrite - and somehow you're still not inspired.

But, this week wasn't like that! I knew I needed a Barrier spell, and I just needed to build it.

The Concept

Continuing the theme of, err, being inspired by Magicka, I wanted summoning Earth + Shield to create an impassable barrier: 1

Concept sketch of a barrier rising from the earth, then retracting rapidly
Idea: a barrier spike thrusts upwards from the earth to ward off melee attackers and projectiles.
(Concept art? No problem, I can do concept art!)

Conceptually, this is pretty straightforward, right? Just make a bunch of atoms slide up from the earth and we're done!

Moving Atoms

But... in my homegrown game engine, to move atoms as a group, they have to be in a moving body - linked to the rigid body physics engine.

And as far as the physics engine is concerned, a body must be one of two types: 2

I figured dynamic bodies wouldn't work well for this because rock barriers shouldn't be moveable by any other objects, but maybe we just try it?

Spikes as dynamic bodies: okay yeah, nah, I was right - this is not a great approach.

But kinematic bodies come with a big caveat: they will do whatever I tell them to do.

So you're meant to use them very carefully: moving platforms in a level editor, or bullets that disappear when they hit things - that sort of thing.

Letting a player place a moving kinematic body pretty much wherever they want? In the presence of other (dynamic) physics objects?

That's asking for trouble.

Handling Dynamic Bodies

Luckily, I realized that in this game there are only two types of dynamic physics objects: 3

  1. Physics objects that explode.
  2. Physics objects that don't matter.

So, I figured out an easy fix: spikes make explosive things explode instantly.

Explosive props (like this rocket) explode on contact with a moving spike.

And for things that don't matter, like corpse ragdolls, well, I just turn off collisions between spikes and those things.

Will I ever need a physics object that can't explode but still matters? Hopefully not!

Handling Characters

Characters, like players and enemies, are supposed to be blocked by the spike.

But since you can place a spike anywhere, you can also trap players and enemies inside spikes, so they try to stop that:

Spikes enthusiastically push characters away from their center... maybe a little too enthusiastically?

As a bonus, it makes characters unable to stand still on the edge of the spikes, which makes enemies less adept at jumping over them.

Destroying Spikes

One thing I got "for free" from my engine was that the spikes were destructible from the get-go:

You can destroy spikes with spells that destroy terrain... okay you got me, this didn't work well out of the gate.

Except, well, spike pieces are not meant to float in mid-air like that. 4

Some really tedious coding later, it worked a bit better:

Cutting spike pieces off acts like detaching the spike pieces from the main spike.

It might be cool to have those other spike pieces dissolve into sand once the spell ends,5 but I haven't implemented that.

Spiking Spots

Spikes slide upwards as intended, but in some spots the sliding looks horrible:

Spikes sliding from below thin platforms look silly, and spikes can pierce ceilings.
(Spike movement slowed down so you can see it clearly.)

A neater solution might be to grow the spike as it slides up, and stop sliding when it hits a ceiling. 6

Lastly, the logic for where to place the spike also needs a bit of work still - it finds the lowest point in front of you, but sometimes that's on a platform way below you. 7

Elemental Effects

As always, each element you mix into (or repeat in) your spell adds an effect:

For example, water will make spikes give you a jump boost, and fire adds some offense to your defense.

But I'm still deciding what mixing more Earth elements into a spike spell should do:

(...all of the above?)

Spiky web build‎

Go summon some spiky barriers: press E, 3, then some more keys of your choice, then left click:

Click to focus, then play with keyboard and mouse. Mobile devices may or may not work! Give feedback.

1

Here is Magicka 2's barrier spell.

Magicka 1's barrier spell is actually more impressive in my opinion, but I couldn't find a nice video of it and I'm out of time to make my own recording!

2

Okay technically there's a third type, "static", which means the body is not expected to move ever. It's kind of pointless, as far as I can tell? You can get that same behavior by making a freestanding collider that isn't attached to any body.

3

It sounds like a joke, but I think this generalization actually holds for lots of games?

Consider how player characters can throw physical objects at non-player characters in Skyrim and they don't even blink.

4

Can you guess why they float?

Answer: the spike is a kinematic body, and the logic that detects breaks in bodies (when atoms get destroyed) makes the new body be kinematic too.

The controlling spike logic doesn't realize the spike split, so it just leaves it.

5

Especially since I just realized that such spike pieces probably get glitched out by a new spike that spawns under them. Hmm...

6

For just fixing the rendering portion, it would be possible to use a stencil.

But it's not a pure rendering problem - right now, the spike actually exists below the platform for a couple frames, and could conceivably interfere with things there.

7

So should the spike always be on the same platform as you? But what if you're on the edge and there's no space? And what if you're mid-air when you cast it?

◂  Writing These Updates
News index