How to create sandworms that poke out of platforms?

Hi, I’m developing a platformer and the second zone (ie, levels 5-10) takes place inside a desert with worms. I want it to be so that particles appear where the worms are going to come and when players cross that vertical plane, they stick out and quickly go back in again, and can only be damaged by jumping onto their sides. However, I’m having a lot of trouble implementing this, as this is my first game. How do I do it?

Hi The_Draco_Dev,

Could you describe a bit which part of what you mentioned gives you trouble? Creating the particles? Making the worms come out upon collision?

The particles and side collision, mainly. I was able to make them come out with sprite variables, although it was quite tedious. However, I need the particles to come out only when the worms are inside, and they are retracting back. Also, I’m unable to find how to make it so that the worms are only deleted if they are jumped on onto the sides.

Could you post your events and maybe also a screenshot of your scene with the worms?

Sure. (Note - I’m using temporary sprites for the worms, and I’ve been unable to make particles nor add side collision to kill them. This code is only for making the worms go up. I also use a sprite FinalChecker to make sure that they stop at a certain point).

Here is the screenshot you asked for as well (sorry for the bad background color, I’m using it as a placeholder):

Okay, but why is that? As far as I understand the problem, you just need to create a particle object at the point where your worm is about to appear / disappeared?

So your Platformer_Character is killing the worms, if it hits them from the side? A simple option for testing that is to use a short raycast that is cast from the character horizontally (maybe when it is in a certain distance to a worm). If the raycast hits a worm, it is like a collision and the worm can be deleted.

Instead of using a force, consider tweening the worm’s position along the Y-axis for a set distance, pausing and then retracting it with another tween. Then there’s be no need to place an OtherChecker or FinalChecker objects above each worm.

I’m struggling with making the particles dissapear for a certain time, then come back. I’m also struggling with making the worms go out fast, and then retract slowly.

You can easily delete and create the particles - depending on your conditions (e.g. timer, amount of particles). In the particle-object menu you can set a certain amount of particles for the tank and check the ‘Delete when out of particles’ option.

That’s something you can easily do, if you follow MrMen’s suggestion above and use tweens for moving your worms.

2 Likes