Gamejam Devlog - Timedust v0.0.8 - Animated Spikes


I made a small breakthrough when I was working on the animated spikes. Some research eventually lead me to understand how to use the frame animation number in code.
This revealed itself very useful, as it gives me more direct control and not like what I did with the suspended trap, I can have my collision mask following the animation, and I don't depend of a hazardous combination of an AnimatedSprite and a AnimationPlayer nodes

How does it works? Well I defined two different colliision masks spikes : halfway out (CollHitboxMid) and fully out (CollHitboxFull)
When the spikes are hidden, well, they are in the ground so we don't need a collision mask ^^
Then I use the built-in boolean disabled property which allows me to deactivate and reactivate the mask at will.

01- Spikes are in the ground: both collision masks are disabled
02- Spikes are halfway out: CollHitboxFull is disabled and CollHitboxMid is enabled
03- Spikes are fully out: CollHitboxFull is enabled and CollHitboxMid is disabled

it's a bit boring code writing, but it works perfectly ^^

I could have define one collision mask for each sprites, but I think it wasn't really worth it. However, in case the spikes would have been more like longer spears, it would have make sense to have more precision.

Here is a slow motionned Gif. The overlapping grey boxes are the two collision masks.
If you watch carefully, you'll see that the full mask (full blue square) is only active when the spikes are fully out.

timedust devlog

Collision masks are visible depending the animation's frame

In physics process, I use a variable f to get the current animation frame:
f = $AnimSprite.frame

Then I use the variable to test different conditions, corresponding to the spikes states, and then I activate or deactivate the collisions masks accordingly.

Timedust devlog animated spikes collision masks

You won't always necessarily need two distinct animations for the spikes going in and out. I choose to do so because of my Timedust system which actually affects how long are the spikes in the ground, rather than their animation speed.
By default, the resting time between the two is very short, and defined by a variable assigned to a Timer node. When Timedust effect is on, that resting time is replaced by another greater variable. When Timedust wears off, the resting time goes back to it's default value.

Timedust devlog animated spikes

Get Timedust - Jam Edition

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.