Download

Event Hit. (The problem with the arkanoid)

Hi, everybody
I’m making an arkanoid and I ran into a problem:
I have many blocks in one scheme, I added them using a script
I need the block that the ball hit to change its texture after the first hit and be destroyed a second time (algorithm for one block: hit - > changed color -> hit again - > destroyed)
But unfortunately for me it comes out in a different way: if the impact is in one block, and then in another block, the first block will change color, and the second will be destroyed, although it should also change color.
I hope the idea is clear, I didn’t think it would be so hard to describe!
I hope you can help

Maybe you can try this in different ways.
Create parent object for your block.
Add the following variables:

  • CurrentHit (increase +1 on every hit)
  • MaxHits (when CurrentHit == this destroy the block)
  • (array) for static meshes of blocks or material index whatever you use. Use CurrentHit as index on every hit.
    OnHit simply add CurrentHit+1, check if equal with MaxHits and destroy if true, otherwise change color/mesh/material with the current index.

In this way you can create various blocks and change above variables for different effects.

Have you tried giving each block health and deducting half on hit?

Spawn block with health 1.0 (float).
On Hit deduct 0.5 health -> Branch Is health == 0 (true) -> destroy, (false) -> set material.