Announcement

Collapse
No announcement yet.

Destructible Minecraft Blocks [WIP]

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [PROTOTYPE] Destructible Minecraft Blocks [WIP]

    Hey all.

    I recently got a massive system upgrade that has enabled me to finally start playing with the new unreal editor.
    So I've committed myself to a simple project: Interactive Minecraft-style blocks that can be destroyed by shooting them.

    I've made some good progress so far with the following steps figured out:
    -Create a 3d cube
    -map UVs
    -import static mesh into unreal editor
    -create a texture, then a material
    -create a blueprint class with the following functionality: each cube has a health value defined by a float variable (ActualBlockHeath), cube detects damage and subtracts the amount from ActualBlockHealth, the value of ActualBlockHealth for a given block is printed to the screen whenever it changes, when ActualBlockHealth <= 0 the block disappears via destroy component. Here's an image of the event graph.

    Here's a video showing the above implementations in action: https://www.youtube.com/watch?v=DdHIEeKsp6M

    There's some work yet to be done before I call it finished, and I'll need help because I am new to all of this (what you see in the video is the product of ~3 days of learning and work :P).
    Any and all assistance is greatly appreciated!!!

    ==========================================
    < TO DO / I need help: >


    1. [Almost Done]AsAs blocks are being broken in minecraft, cracks gradually form on the surface. I want a similar look, but the degree of cracks that appear should be proportional to the initial health of the block (eg variable: InitialBlockHealth).
    Minecraft uses 10 different textures for the different stages of cracking, so there will be a different appearance for every 1/11th of the block's initial health value. (the first ~9.1% damage wont show any cracks.) I'm still working out how to script this behavior.
    Click image for larger version  Name:	Destroy1.png Views:	1 Size:	296 Bytes ID:	406581Click image for larger version  Name:	Destroy2.png Views:	1 Size:	359 Bytes ID:	406585Click image for larger version  Name:	Destroy3.png Views:	1 Size:	428 Bytes ID:	406583Click image for larger version  Name:	Destroy4.png Views:	1 Size:	497 Bytes ID:	406589Click image for larger version  Name:	Destroy5.png Views:	1 Size:	589 Bytes ID:	406584Click image for larger version  Name:	Destroy6.png Views:	1 Size:	671 Bytes ID:	406587Click image for larger version  Name:	Destroy7.png Views:	1 Size:	746 Bytes ID:	406588Click image for larger version  Name:	Destroy8.png Views:	1 Size:	895 Bytes ID:	406586Click image for larger version  Name:	Destroy9.png Views:	1 Size:	927 Bytes ID:	406580Click image for larger version  Name:	Destroy10.png Views:	1 Size:	953 Bytes ID:	406582
    I need a way to overlay these cracking textures over the base textures using something like a "multiply" effect using blueprints to achieve the following effect in-game:
    Click image for larger version  Name:	example4.png Views:	1 Size:	56.2 KB ID:	406590
    I'm not sure where to start on figuring out how to make this work, so any pointers is bigly appreciated!


    2. [Complete] Blueprint scripted sound to be played upon block destruction. (This should be easy enough to figure out, pending retrieval of ripped sounds to play with.)

    3. [Complete] Sprite-based particle explosion to be spawned upon block destruction. The emitter should be able to automatically retrieve the block base material and use the same material for the exploding particles. (Haven't looked into this at all yet, so I don't know what I don't know.)


    </ TO DO / I need help: >
    ==========================================
    Ultimately I want to end up with a class where can create any full size Minecraft block simply by changing the base material, amount of health the block has, and the destruction sound effect-- all without messing with blueprints.


    FAQ: Q: This is lame who even wants Minecraft blocks in UT? Why are you doing this?
    A: I've never 3d modelled before and this seemed like a decent beginner project to sorta feel out the editor. Also I kinda like Minecraft therefore UT needs Minecraft maps.

    Q: What about the other non-cube shaped blocks like stairs?? Or TNT?
    A: Wanna finish these cubes first, then I'll consider adding other shaped block classes. TNT's exploding behaviour should be easy enough to add to a finalized cube class but I'm not quite there yet.

    Q: Will you share completed assets for use by the community?
    A: If there's any interest, yeah!
    Last edited by Envarion; 10-06-2019, 02:50 PM.

    #2
    Okay! I've made some decent progress.

    Here's my blueprint so far:
    Click image for larger version  Name:	BPsofar.PNG Views:	1 Size:	322.7 KB ID:	406600


    2. [Complete] (Blueprint scripted sound to be played upon block destruction. Sound should attenuate with distance from the block.)
    >>>Since each type of block in Minecraft can play 1 of up to 3 different sounds when destroyed, I made it possible to assign 3 different sounds to my block class. Upon destruction, one of these sounds will be picked randomly and played. I added a volume multiplier option too since UT's weapons are very loud and obscure the sound of the breaking blocks.

    Visible options:
    Click image for larger version  Name:	Options.PNG Views:	1 Size:	685.7 KB ID:	406599

    Sound Blueprint: (I know this setup doesn't give an exactly equal probability for 1 of the 3 sounds to be played, but it's close enough for now.)
    Click image for larger version  Name:	SoundBP.PNG Views:	1 Size:	283.2 KB ID:	406601

    While the sounds do play, I am having problems with attenuation. When the sound plays, it should appear quiet from a distance and loud up close. Here's a video demo where blocks at different distances produce the sound effect at the same volume.

    Once I sort this out I'll consider "2." [Complete].


    3. [Complete] (Sprite-based particle explosion to be spawned upon block destruction. The emitter should be able to automatically retrieve the block base material and use the same material for the exploding particles.)
    >>>I've created and added a particle emitter to my block class, and successfully implemented the code to toss some particles when the block is destroyed. However I am having problems automatically texturing the particle emitter to correspond with the material of the block.

    In fact, for some reason I can't even manually change the emitter's material from within the blueprint (which may be related to why my BP script isn't working).

    Auto-texture BP:
    Click image for larger version  Name:	BP-texture.PNG Views:	1 Size:	150.9 KB ID:	406602

    Particle burst demo video


    ===========================================================



    Last edited by Envarion; 10-05-2019, 12:33 AM.

    Comment


      #3
      Not to dissuade you from what you're doing, but you are likely to get a lot more help for this type of endeavor on the standard Unreal Engine forums. The Unreal Tournament forums rarely see more than 1 or 2 new posts a day, since UT has been abandoned for a long time now.
      Join Project: Open Tournament: OpenTournamentGame.com | Project Trello | Discord | YouTube

      Subscribe to /r/UnrealSeries - The subreddit for free & uncensored discussion of Unreal series games!

      Unreal Prime Weapons: Impact Hammer | Enforcer | BioRifle | Shock Rifle | Link Gun | Ripper | Minigun | Flak Cannon | Rocket Launcher | Sniper Rifle | Grenade Launcher | Dispersion Pistol

      Comment


        #4
        Originally posted by Wail View Post
        Not to dissuade you from what you're doing, but you are likely to get a lot more help for this type of endeavor on the standard Unreal Engine forums. The Unreal Tournament forums rarely see more than 1 or 2 new posts a day, since UT has been abandoned for a long time now.
        Thanks Wail, I'll do that and continue to post progress here.


        Originally posted by Wail View Post
        UT has been abandoned ...
        This old news still kills me. At least there's alot of familiar faces still playing.

        Comment


          #5
          2. [Complete] (Blueprint scripted sound to be played upon block destruction. Sound should attenuate with distance from the block.)
          >>> Problem solved: just had to create my own sound attenuation class (Distance algorithm = Natural Sound) and use that in my blueprint. (-- existing attenuation classes were no good.)

          Still having trouble with "1." and "3."

          Comment


            #6
            About problem 1:
            I think you can use an animation flipbook in the material and then make a parameter of which frame it uses and then control that parameter via Blueprint.
            You will need to combine all the frames into 1 texture file (GlueIT is very handy to make spritesheets like this) and set the UVs correctly so you can flip through.

            You could make a spritesheet of only the cracks and then later add a multiply node in the material.
            Make the texture a parameter texture so it's easy to apply the effect on a new material instance for other block types.

            About problem 3:
            - The parameter is set to none, it needs to match the texture parameter you have set in your particle system
            - You can set that material param in the construction script

            - Don't forget to test it online. Changing materials needs some replication magic for other players to see it too. You could try out setting a dynamic material instance.
            Last edited by Metalfist; 09-28-2019, 06:07 AM.
            -Fn>Metalfist
            ---------------------
            BT-CrashOut | CTF-AsteroidDrill | UT99 Ports&Muts | Nyandeemer | LogoSplash | Unreal Papercrafts | Unreal Monsters | ChaosUT | UT-SLV: Strangelove | DeviantArt | Zunnie's Mug

            Comment


              #7
              Originally posted by Metalfist View Post
              About problem 1:
              I think you can use an animation flipbook in the material and then make a parameter of which frame it uses and then control that parameter via Blueprint.
              You will need to combine all the frames into 1 texture file (GlueIT is very handy to make spritesheets like this) and set the UVs correctly so you can flip through.

              You could make a spritesheet of only the cracks and then later add a multiply node in the material.
              Make the texture a parameter texture so it's easy to apply the effect on a new material instance for other block types.

              About problem 3:
              - The parameter is set to none, it needs to match the texture parameter you have set in your particle system
              - You can set that material param in the construction script

              - Don't forget to test it online. Changing materials needs some replication magic for other players to see it too. You could try out setting a dynamic material instance.
              Thanks a ton Metalfist! This information you've provided seems very promising

              I've got a little more time off work to mess around with this so we will see how it goes.

              Comment


                #8
                3. [Complete] (Sprite-based particle explosion to be spawned upon block destruction. The emitter should be able to automatically retrieve the block base material and use the same material for the exploding particles.)
                >>> Problem solved: I've put hours into trying to make this work-- feels good to get it over with finally! So a few learnings...

                1. In the material "edit" window, this needs to be checked:
                Click image for larger version  Name:	20191004_215800002.jpg Views:	1 Size:	321.5 KB ID:	406708

                2. Setting up a material parameter-- I was missing this step and had a hell of a time figuring this out. I found some instructions here by user "Spoondog" which worked: https://answers.unrealengine.com/que...n-cascade.html
                Click image for larger version  Name:	20191004_221200008.jpg Views:	2 Size:	529.4 KB ID:	406712

                3. For some reason setting the material doesn't seem to work in the construction script, but it does work in the event graph using "Event Beginplay" with the exact same nodes.

                This doesn't work:
                Click image for larger version  Name:	20191004_220600003.png Views:	1 Size:	132.7 KB ID:	406709
                This works:
                Click image for larger version  Name:	20191004_220600004.png Views:	1 Size:	151.3 KB ID:	406710
                So that's a bit weird.

                Success demo video link HERE.


                Now to figure out "1."
                Attached Files
                Last edited by Envarion; 10-05-2019, 12:34 AM.

                Comment


                  #9
                  1. [Almost Done]As blocks are being broken in minecraft, cracks gradually form on the surface. I want a similar look, but the degree of cracks that appear should be proportional to the initial health of the block (eg variable: InitialBlockHealth).
                  Minecraft uses 10 different textures for the different stages of cracking, so there will be a different appearance for every 1/11th of the block's initial health value. (the first ~9.1% damage wont show any cracks.) I'm still working out how to script this behavior.

                  Cracking behavior is working nearly as intended. It works on all blocks except for those with transparency-- a consequence of using the multiply mode. So this will be a matter of messing with the materials to get the intended effect.

                  4. [Complete] In the same day I got TNT behaviour working with the following features!!!
                  -TNT fuse timer begins when block health is depleted.
                  -Editable boolean can turn a static TNT block into a moveable one upon activation of the fuse timer (so players can now play hot potato with the explosive by shooting it )
                  -The TNT block blinks (glows) white to indicate fuse activation, and can be set up to have a more subtle (eg: red-ish glow) between white blinks. Both colors are fully configurable.
                  -The TNT block breifly grows in size just before it detonates-- true to the source of inspiration.
                  -The TNT block causes damage to surrounding players and blocks, and can ignite nearby TNT as well to create a chain reaction.
                  -Players can be protected from the explosion if they are shielded (line of sight) by blocks with enough health to withstand it.
                  -TNT blocks have a VERY SLIGHTLY randomized fuse timer (we're talking hundredths of a second-- basically imperceptible) this allows adjacent and simultaneously activated TNT blocks to be launched a distance by the other's explosion.
                  -If a player triggers a TNT fuse timer, that same player will be credited for any kills caused by that same TNT block.


                  Demo video featuring: Cracking Behaviour and TNT
                  Last edited by Envarion; 10-07-2019, 02:43 AM.

                  Comment


                    #10
                    1. Im not entirely sure how u set up the material, but you can also try the "add" node instead of the "multiply" node

                    Btw the last video is set to private.
                    -Fn>Metalfist
                    ---------------------
                    BT-CrashOut | CTF-AsteroidDrill | UT99 Ports&Muts | Nyandeemer | LogoSplash | Unreal Papercrafts | Unreal Monsters | ChaosUT | UT-SLV: Strangelove | DeviantArt | Zunnie's Mug

                    Comment


                      #11
                      Originally posted by Metalfist View Post
                      1. Im not entirely sure how u set up the material, but you can also try the "add" node instead of the "multiply" node

                      Btw the last video is set to private.
                      Oh **** thanks for the heads up. I took a look at it and youtube says the video is in a "draft state" with no visible privacy options and the 'publish' button is greyed out. I've never seen this before so I'll probably have to reupload the video on my next days off work. Very frustrating because I was very excited to show off my TNT.
                      EDIT: The video is fixed now!

                      Meanwhile heres some pics of the material setup:
                      Click image for larger version  Name:	20191009_162500010.png Views:	1 Size:	342.6 KB ID:	406735

                      This is very similar for almost every other material I have:
                      Click image for larger version  Name:	20191009_162700011.png Views:	1 Size:	435.7 KB ID:	406736


                      Multiply just doesnt work very well with transparency. The add solution we come up with may need to turn all white and gray color into some corresponding level of transparency for the cracks. Gonna need more time to look into this.


                      Some pics of TNT carnage:
                      Click image for larger version  Name:	20191009_162800012.png Views:	1 Size:	597.9 KB ID:	406737
                      Click image for larger version  Name:	20191009_162800013.png Views:	1 Size:	607.2 KB ID:	406738
                      Click image for larger version  Name:	20191009_162900014.png Views:	1 Size:	626.5 KB ID:	406739
                      Last edited by Envarion; 10-10-2019, 06:09 PM.

                      Comment

                      Working...
                      X