Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Attempting to create a 'damage' effect that worsens over a small time period

Discussion in 'Getting Started' started by MinorCheetah788, Jun 4, 2023.

  1. MinorCheetah788

    MinorCheetah788

    Joined:
    Oct 30, 2021
    Posts:
    2
    Hi,

    I'm currently working on a project where I'm creating a replica of Minecraft using Unity's High Definition Render Pipeline (HDRP). As a newcomer to Unity, I've hit a bit of a roadblock that I'm hoping someone here can help me navigate. I'm well aware that the scope of Minecraft is well out of my range at the moment, and I am starting VERY slowly and just adding some simple, core features. I have run into a bit of trouble with one of them though.

    My goal is to mimic the original Minecraft's block-breaking mechanic, where a block breaks in stages as you continuously hold down the mouse click. To achieve this, I have prepared 9 separate files. Each file is transparent, with the exception of cracks that progressively worsen from one image to the next.

    My challenge lies in creating a shader or material that can effectively display this gradual degradation through my script. I've been struggling with this task and would greatly appreciate any guidance or advice on how to proceed.

    I have tried using some shaders, but I am admittedly very new to shaders and I keep running into issues. At one point, I was close, but there were too many issues - half of the block would be invisible, and the same effect would apply to all blocks with the shaders applied. I was thinking of using animation but wouldn't really know how to do this either.

    Thanks!
     
  2. MinorCheetah788

    MinorCheetah788

    Joined:
    Oct 30, 2021
    Posts:
    2
    Hi,

    I have created a ShaderGraph to attempt this effect. It is attached to this post.

    Strangely, it works in the ASE - If I increase the value of DamageLevel, I see the cracks progressively appear as it gets bigger. However, in-game, I only ever see one stage of the cracks, so I know I have done something wrong, but I am not sure how to correct it.

    Thanks for any help.
     

    Attached Files: