Stencyl 3.4.0 is now out. Get it now!

Destructible Block

Okay guys! Having difficulty with a semi advanced topic and can't get any related posts. What I am trying to do within my game is have my player able to destruct dirt tiles upon hitting them TWICE. I also need to play animation the first time the player hits the block to let the player know that block can be destructed upon hitting it again. I've set up some really basic Booleans which I thought would execute this process...it doesn't.

Any help?

Additional info: what's happening right now is that the first time my player hits the block it's just disappearing automatically.

Exportforce

  • *
  • Posts: 90
The problem is, the "hits" thingy is being called per frame. So, when the player stands on the tile it's gone after 3 frames.

Bombini

  • Posts: 831
I dont fully understand what you want to achieve: Hitting twice? Like when coming back to it or after time? Please explain.

The problem is, the "hits" thingy is being called per frame. So, when the player stands on the tile it's gone after 3 frames.

I don't fully understand. What "hits thingy"?

I dont fully understand what you want to achieve: Hitting twice? Like when coming back to it or after time? Please explain.

Like when the player collides with any part of this block I want it to show one animation and gen if the player hits it again I want it to basically kill itself and disappear

Sorry for the grammar. Typing on an iPhone.

Bombini

  • Posts: 831
I would to it with a region (if inside region -1 or +1 and set a boolean to true - othwerwise if not in region set boolean to false).

Rimrook

  • *
  • Posts: 237
I've done my own version of a destructable tile.
What I did what make a breakable block actor. Pretty straight forward stuff. But when this block is placed underneath level tiles, it hides until it is hit, then it removes the tiles above it and shows itself.

A caveat is the physics. Tiles can be set to have a hitbox, but if the tile changes, the physics stay the same, creating invisible walls. I solved the wonky physics by making all tiles non solid, then on a separate 'physics tile' layer, I place these orange debug tiles I made that have physics shapes. That way, as I so choose, anything can be solid or not, and I can layer up my graphics, and destroyable terrain, without too much worry.

If you know anything about the Super Metroid editor and hacking, Nintendo used a similar 'behind the scenes' system to control tile destruction and passability. Of course, Stencyl is a far more sophisticated engine with far more capabilities. This is just one solution.

Bombini

  • Posts: 831
. Tiles can be set to have a hitbox, but if the tile changes, the physics stay the same, creating invisible walls. I solved the wonky physics by making all tiles non solid, then on a separate 'physics tile' layer, I place these orange debug tiles I made that have physics shapes. That way, as I so choose, anything can be solid or not, and I can layer up my graphics, and destroyable terrain, without too much worry.

Not true for simple physics btw

Rimrook

  • *
  • Posts: 237
I was unaware of that since I rarely work with simple physics. Good to know.

Bombini

  • Posts: 831
I was unaware of that since I rarely work with simple physics. Good to know.

It is a game changer if you dont new Box2D. Makes your life if you work a lot with tiles much easier.