In this video we will destroy cube into pieces and give it an explosion effect. We will use OnTriggerEnter, CreatePrimitive and AddExplosionForce. Download Script: drive.google.c...
Пікірлер: 189
@learngamecreating13086 жыл бұрын
Don't forget to open SUBTITLES for details. Leave a commend for your questions. Experts will help you. Let's learn together, help each other.
@natalieweishuhn5214 жыл бұрын
#youreWelcome using System.Collections; using System.Collections.Generic; using UnityEngine; public class Explosion : MonoBehaviour { public float cubeSize = 0.2f; public int cubesInRow = 5; float cubesPivotDistance; Vector3 cubesPivot; public float explosionForce = 50f; public float explosionRadius = 4f; public float explosionUpward = 0.4f; // Use this for initialization void Start() { //calculate pivot distance cubesPivotDistance = cubeSize * cubesInRow / 2; //use this value to create pivot vector) cubesPivot = new Vector3(cubesPivotDistance, cubesPivotDistance, cubesPivotDistance); } // Update is called once per frame void Update() { } private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Floor") { explode(); } } public void explode() { //make object disappear gameObject.SetActive(false); //loop 3 times to create 5x5x5 pieces in x,y,z coordinates for (int x = 0; x < cubesInRow; x++) { for (int y = 0; y < cubesInRow; y++) { for (int z = 0; z < cubesInRow; z++) { createPiece(x, y, z); } } } //get explosion position Vector3 explosionPos = transform.position; //get colliders in that position and radius Collider[] colliders = Physics.OverlapSphere(explosionPos, explosionRadius); //add explosion force to all colliders in that overlap sphere foreach (Collider hit in colliders) { //get rigidbody from collider object Rigidbody rb = hit.GetComponent(); if (rb != null) { //add explosion force to this body with given parameters rb.AddExplosionForce(explosionForce, transform.position, explosionRadius, explosionUpward); } } } void createPiece(int x, int y, int z) { //create piece GameObject piece; piece = GameObject.CreatePrimitive(PrimitiveType.Cube); //set piece position and scale piece.transform.position = transform.position + new Vector3(cubeSize * x, cubeSize * y, cubeSize * z) - cubesPivot; piece.transform.localScale = new Vector3(cubeSize, cubeSize, cubeSize); //add rigidbody and set mass piece.AddComponent(); piece.GetComponent().mass = cubeSize; } }
@stodgystarch47985 жыл бұрын
I don't know if this is already somewhere in the comments, but something this explosion script does is overpopulate the scene with new cubes, so here is a quick fix for it :) in the createPiece function, at the very bottom, insert this little bit of code for an automatic deletion of the pieces so you don't encounter lag : Destroy(piece, UnityEngine.Random.Range(0.5f, 5f)); What this does; it grabs every new piece you just created, destroys is in a randomized way, clearing your now *very* populated hierarchy in a way that all the tiny cubes don't go away at once, making it look a bit more natural. Hope that helps :D
@learngamecreating13085 жыл бұрын
Yes, there is a comment like that but random idea was awesome. well done my friend and thank you for sharing
@erjuanjojj2 жыл бұрын
only one video?? this is one of the best tutorial formats I've ever seen, direct and detailed, please do more :(
@kagigreenscreen5 жыл бұрын
oh this is very very nice coding thank you for this many thanks and thanks for the download script etc makes old slow unity learner very happy :)
@youssefabdulaziz21335 жыл бұрын
that's amazing,keep going,pal👍👍
@CustomClass55 жыл бұрын
This was an excellent tutorial.
@mohsinnaseer41274 жыл бұрын
explosionPos, explosionUpward, explosionRadius is not defined in video
@matanyamin12 жыл бұрын
Fantastic video! Very clear and straight forward. Thanks.
@GameDevNerd3 жыл бұрын
Clever little bit of code!
@tonysang36604 жыл бұрын
exactly what i'm looking for thank you so much!
@oscarkiloproductions58605 жыл бұрын
Hello! I was just wandering if sometime you could create a tutorial on how to make a grenade that when it explodes, it leaves a crater. It would be great for my new game!
@casper22774 жыл бұрын
Thanks! The tutorial was easy to follow and the explosion looks amazing👍🏻
@anix75334 жыл бұрын
Can you help me ? Unity says that there is a compiling error with the script but VS code doesn't find any problem
@Zarakikov4 жыл бұрын
Very nice, thank you!
@brunosallesdev3 жыл бұрын
Great technique!
@d-bi59603 жыл бұрын
Thank you for a very good script))
@acanaldelbuencontenido3 жыл бұрын
Amazing video, thanks.
@rahulkukreti64915 жыл бұрын
Excellent, Thanks alot :)
@xilongzhang68563 жыл бұрын
Could anyone tell me how to define explosionRadius, explosionForce and explosionUpward? 😭 I don’t know what are they, and they are not defined...
@xilongzhang68563 жыл бұрын
ohh for anyone that is wondering. I found it in the file linked in description. He skipped a few code in the video but you can find it when you download the code x
@itamarashofiniaw.a.63942 жыл бұрын
@@xilongzhang6856 Thanks a lot!
@Alex-tn7pv3 жыл бұрын
Great stuff!!!!
@mohamedahmedahmedfathi93822 жыл бұрын
This is an amazing script thank you very much
@batuhanartan5 жыл бұрын
Great Tutorial .. .thank you very much :)
@melom.4 жыл бұрын
What about the cutted objects (explosion radius, explosion force and explosion Upward?)
@Daviality Жыл бұрын
Very goods script! I modified it so I can use this on thin cards
@ЕвгенийШиряев-г5х5 жыл бұрын
Thanks a lot, very helpful
@ManaBlend3 жыл бұрын
Thank you! So much verygood script🎁
@Aliozka5 жыл бұрын
Hey great tutorial thanks.. How do you change the colour of the cubes after the blast.. Thank you..
@learngamecreating13084 жыл бұрын
This is the most asked question :) read comments
@Aliozka4 жыл бұрын
@@learngamecreating1308 i manage to do it 👍😅
@learngamecreating13084 жыл бұрын
@@Aliozka Perfect, sorry for late answer
@Aliozka4 жыл бұрын
@@learngamecreating1308 no worries mate👍ones again great tutorial thank you 👌🏼👏
@Adul1k4 жыл бұрын
@@Aliozka how did you do it please :-)
@tim68736 жыл бұрын
Amazing work! Can even work with "Bullets" !! thank you! Make more videos please and thank you
@deadly_artist6 жыл бұрын
thank u u broke my unity
@learngamecreating13086 жыл бұрын
Did you fix your unity? can we help you?
@deadly_artist6 жыл бұрын
I did, always breaks whenever I run that program though
@veggiearchon57784 жыл бұрын
thank you man it worked perfectly :D
@jontyblair80345 жыл бұрын
Very nice thanks man👌
@learngamecreating13085 жыл бұрын
Follow for more, new tutorials coming
@omercenikli26544 жыл бұрын
Thank you for video. Nice job
@wariskbr5 жыл бұрын
Very Helpful, Appreciate it
@anix75334 жыл бұрын
Thank you so much for this video!
@L33T_Taco5 жыл бұрын
Thanks for the tutorial @LearnGameCreating quick question thought what can i do to the code to make the cube explode outward in a specific direction? like say if i applied this to a moving object, which i have done successfully, how would i make the explosion throw the smaller cubes forward in the direction its going.
@learngamecreating13084 жыл бұрын
use smaller mass, and let engine do it for you
@TheShiftingSounds6 жыл бұрын
How come anyone dislike! Amazing work a d thanks. Will work on this tomorrow.
@learngamecreating13086 жыл бұрын
thank you
@funkupgamer53645 жыл бұрын
Awesome...!!
@vilanstrikegaming51143 жыл бұрын
Does it work for spheres
@rinodipaola7614 жыл бұрын
Congratulations! Thank you
@starchaser285 жыл бұрын
This is awesome! Is there a way to define another model that results from the explosion rather than smaller cubes? Like butterflies. :)
@learngamecreating13085 жыл бұрын
Yes, you can do it, //add prefab variable top of script public GameObject piecePrefab; //old code (create cubes) piece = GameObject.CreatePrimitive(PrimitiveType.Cube); //new code (create any object) piece = Instantiate(piecePrefab, new Vector3(0, 0, 0), Quaternion.identity); //you can set position when you create or, after create like we did in script //don't forget to drag&drop your butterfly prefab to scripts "piecePrefab" variable in editor. good luck 🤞
@stevendeprez53924 жыл бұрын
came for the tutorial stayed for the music
@learngamecreating13084 жыл бұрын
Perfect :)
@XONRk4 жыл бұрын
I was looking for this for a million years Just kidding 😁
@umeshy6 жыл бұрын
Good tutorial! thanks
@atakanbacak8281 Жыл бұрын
for everyone public float explosionForce = 50f; public float explosionRadius = 4f; public float explosionUpward = 0.4f;
@chris.s.m.r4989 Жыл бұрын
you are mi savior
@loganjones78725 жыл бұрын
Friend, great video. However, can you help me understand why you must subtract pivot distance and what is it exactly.
@learngamecreating13085 жыл бұрын
Because main cubes pivot is center of object, if we create pieces over this pivot point (we adding positions to object position (center point)) so pieces was moving side, if you check there in video again, you will notice, that's why we calculate half of the cube, and subtract that position from pieces, then new created cubes same position as old destroyed cube. I hope it's clear now, good luck, best wishes
@urospocek46686 жыл бұрын
You didn’t set explosion Force, Radius and Upward but you have use them!?? How to define them to work?????????????
@茨城童子-n1i6 жыл бұрын
Look at 4:48. explosion Force, Radius and Upward are public variable
@dimitrioskoulialis61175 жыл бұрын
Thanks for the tutorial really helpful! What is the name of the song in the background?
@learngamecreating13085 жыл бұрын
Nice to see it helps you, music : Exotics - Kevin MacLeod
@MadhanLeMan6 жыл бұрын
Thanks!. And can we add a custom GameObject instead of using cubes. I tried adding a public GameObject piece and it didn't work any ideas??
@learngamecreating13085 жыл бұрын
Yes, you can do it, //remove this line piece = GameObject.CreatePrimitive(PrimitiveType.Cube); //with this piece = Instantiate(piecePrefab); //so we will Instantiate a custom prefab, not Cube primitive. //And declare a prefab variable at the beginning of the script public GameObject piecePrefab; //then drag&drop your prefab in this variable in the editor
@bulletsponge69205 жыл бұрын
How could I adjust the code to have the size adjust to the cube size? For example I have three cubes with different x,y, and z, lengths, but when hit, it all makes the same explosion. I like the sizes of the pieces themselves, I just want the pieces to fill the bigger or wider or taller cubes
@learngamecreating13084 жыл бұрын
I'm gonna make another video about random explosion effect
@djukicdev5 жыл бұрын
Thanks dude.
@learngamecreating13085 жыл бұрын
Follow for more, new tutorials coming
@unamattina60234 жыл бұрын
where did explosionRadius came from?
@xilongzhang68563 жыл бұрын
I want to ask this as well. Where do we get that
@learngamecreating13083 жыл бұрын
I Forgot to put it in the video, check scipt, it's just a variable, public float explosionForce = 50f; public float explosionRadius = 4f; public float explosionUpward = 0.4f;
@frkngz6 жыл бұрын
teşşekkürler çok hoş olmuş.
@StackBrains4 жыл бұрын
DESTROY CUBE INTO PIECES, THIS IS MY LAST RESPAAAWN
@TruuAmbition Жыл бұрын
Anyone have tips on how to create the pieces from a pool of objects as to make the script more performant ?
@PixelTB6 жыл бұрын
I need help, so I have a cube that is a player and it has movement scripts and all that stuff, and there are obstacles and I want when I hit an obstacle my player cube to explode
@learngamecreating13085 жыл бұрын
You can trigger an explosion when the collision occurs. Put this script to your player object, and check when to explode OnTriggerEnter function, as we did in example (we checked if it is the floor)
@iskandermx6 жыл бұрын
Hi! Good work, how can change explotion no only color, texture too. Second question, i make a car and wanna exploition when car touch, how can make this? Best Regards.
@learngamecreating13085 жыл бұрын
//declare texture variable public Texture m_MainTexture; //put these lines to createPiece function material = piece.GetComponent().material; material.SetTexture("_MainTex", m_MainTexture);
@jroy74086 жыл бұрын
Great tuto, thanks! I was wondering whether someone knew how to give pieces the same colour as the main cube??
@learngamecreating13086 жыл бұрын
you can set cubes material color with this lines. //put these lines to createPiece function material = piece.GetComponent().material; material.color=Color.red; //Color.red or you can send a value as parameter, same as main cube's material.color
@anix75334 жыл бұрын
Hey Unity says I should fix some compile errors and that I cant use it bcs of this , but in VS there dont seem to be any errors
@MrsAgathe5 жыл бұрын
Hello, I want my object to explode when I Press "E" for example, instead of Colliding with another object. Can you help me?
@AlexJDev5 жыл бұрын
In the update function, call a getkey function and have explode() in that
@aborayan52686 жыл бұрын
awesome thank you
@damirshabayev3444 жыл бұрын
cool tutorial works too
@anix75334 жыл бұрын
Really? Can you help me , Unity says that there is a compile error while there isn't any ( I even tried copy pasting his code and changing the name of the things that needed to be changed )
@linkspecialproximity5 жыл бұрын
In my project i'm using OnCollisionEnter instead of OnTriggerEnter. I'm new to this stuff and i'm having a hard time figuring out how i am going to explode my cube when i come in contact with an obstacle. i am doing the same as this Pixel guy: "I need help, so I have a cube that is a player and it has movement scripts and all that stuff, and there are obstacles and I want when I hit an obstacle my player cube to explode". There's a player movement and collision script. when i just change "floor" into "Obstacle" it does not work and when i make the obstacles triggers they just fall through the floor haha. Any ideas?
@saif_khan_gamers5 жыл бұрын
Change the tag of the object tht is colliding!
@aleprivi45754 жыл бұрын
Thank you very much for helping! but I have a problem can you help me? how do I change the color of the cubes that are generated? and how do I get rid of them after some time
@learngamecreating13084 жыл бұрын
Please read other comments, you will find the answer, thank you
@sisitech3 жыл бұрын
I dont know if im gonna get any answer on this 3 years after the upload but I cna always try I used this on a prefab but it doesnt look good if a brown crate explodes into white cubes so is it possible to let it create/clone a prefab instead of a cube //create piece GameObject piece; piece = GameObject.CreatePrimitive(PrimitiveType.Cube);
@jung-zen3 жыл бұрын
Here's a comment left by LearnGameCreating (The creator of this video) replying to somebody with a similar issue: Yes, you can do it, //add prefab variable top of script public GameObject piecePrefab; //old code (create cubes) piece = GameObject.CreatePrimitive(PrimitiveType.Cube); //new code (create any object) piece = Instantiate(piecePrefab, new Vector3(0, 0, 0), Quaternion.identity); //you can set position when you create or, after create like we did in script //don't forget to drag&drop your butterfly prefab to scripts "piecePrefab" variable in editor. good luck 🤞
@jung-zen3 жыл бұрын
I'm literally trying this right now, if you could let me know how you get on it would be much appreciated!:) Currently have an issue where the prefabs fall through the floor despite having set the colliders etc...
@sisitech3 жыл бұрын
@@jung-zen I think I know why it goes trough I just had the same object but then I used the Prefab from my asset folder instead of from my hierarchy and now it works, only problem I have now is that it explodes very un realistic, It explodes and stays in a cube of small cubes
@jung-zen3 жыл бұрын
@@sisitech Thanks for the reply, I’ll take a look at this ASAP and get back to you. Mine also faces the same issue
@jung-zen3 жыл бұрын
@@sisitech Try bumping up the explosion force, by that I mean try 3000 or higher.
@coolride14014 жыл бұрын
can you make a video of cutting objects?
@learngamecreating13084 жыл бұрын
For sure
@refikugur2125 жыл бұрын
How can i explode like 10 1 1 cube rectangle one, where collision happens? like from corner
@Minebender94 жыл бұрын
Hey, just wondering how to make the pieces have no gravity, and also make the color orange, (none of the comments worked for me). Someone PLS help. Thanks!
@thefunny_694 жыл бұрын
Minebender9 watch a youtuber named brackeys and look at his how to make a game tutorial and it will teach you everything you need to know
@headshotgamer74223 жыл бұрын
It works m, thanks
@arnaudb43576 жыл бұрын
when i use this script all obects in my scene fly in the air thats fun haha i dont understand why but now i seriously need it triggered on explosions is it an easy thing to do? (sorry french guy speaking english)
@learngamecreating13086 жыл бұрын
Your english flows :) But i can't understand "triggered on explosions" You can trigger it when ever you want, i used trigger collision, you can explode it from your code when ever you want
@arnaudb43576 жыл бұрын
@@learngamecreating1308 I would like to trigger the explosion of gameobjects that are props or walls with a shock wave or a blast. I tried to give the particles several physical properties but the only way it works is with the contact between polygons. I would blowup a max of objects on my map now hahaha ^^ I adapted my script with the different names of particles that I use in my scene but without result :( (im a beginner in C# i use C usually so its hard to adapt even if its similar in lot of ways)
@learngamecreating13086 жыл бұрын
@@arnaudb4357 Ok, you want to filter rigidbodies in AddExplosionForce, cause your all objects explode. Vector3 explosionPos = transform.position; Collider[] colliders = Physics.OverlapSphere(explosionPos, explosionRadius); foreach (Collider hit in colliders) { //check colliders gameobject layer or tag //ofcourse don't forget to set your walls or props tags to 'walls' or whatever you want if (hit.gameObject.tag=="walls") { Rigidbody body = hit.GetComponent(); if (body!=null) { body.AddExplosionForce(explosionForce, explosionPos, explosionRadius, explosionUpward); } } }
@arnaudb43576 жыл бұрын
@@learngamecreating1308 You are very helpful! Merci beaucoup! Im gonna try to understand C# better but i may will be back with more questions hehh Usually i make destroyable objects in blender but it's a long process to make them usable and not too greedy on the performance.
@learngamecreating13086 жыл бұрын
@@arnaudb4357 Your welcome my friend, i will make more videos, follow
@xinyueyang19624 жыл бұрын
BGM is outstanding
@Thesupperals2 жыл бұрын
This is not the best practice. Sure, diagnosing so that code is functioning correctly is a good practice but what you are doing can be achieved with a coroutine, using addressables, not getting components, not adding a rigidbody and not using physics at all. You should think about using a particle system that utilizes an animation trim sheet while things are in air. As soon as they collide and die, you can instantiate an object in place of the dead particle and if you must- add a mesh collider to that instantiated object. On top of all that, the last thing to do is add another coroutine to destroy the object if it commonly occurs. This is best practice. Heck, don't get me started on Enums, Dictionaries, object pooling, Data Abstraction and Scriptable Objects.
@ecel_style2 жыл бұрын
I think you should make educational videos too :)
@gustavjakobsen41606 жыл бұрын
Is there a way to have the cubes destroy themselves after they hit the ground?
@learngamecreating13086 жыл бұрын
If you want to check collision with floor it would be more complicated, but an easy way i can suggest you to use Destroy command. //just put this line to end of createPiece function Destroy(piece, 3); //3 means after 3 seconds, remove object from scene. You can tweak it as you wish :)
@luiscarloscajas48236 жыл бұрын
cool ass video bro
@zaraali21693 жыл бұрын
works! thx!
@breakfastboi33446 жыл бұрын
When ur hp is at 0
@teetehi5 жыл бұрын
Can this code be used on any object for example a tree if I click it it exploded if I make the correct modification to the code and if so can you tell me what to change?
@learngamecreating13085 жыл бұрын
A lot of questions about that, i will post a new tutorial about custom object exploding. But if i should answer, Yes, you can do it, You need small stick mesh objects. //add prefab variable top of script public GameObject piecePrefab; //old code (create cubes) piece = GameObject.CreatePrimitive(PrimitiveType.Cube); //new code (create any object) piece = Instantiate(piecePrefab, new Vector3(0, 0, 0), Quaternion.identity); //you can set position when you create or, after create like we did in script //don't forget to drag&drop your stick prefab to scripts "piecePrefab" variable in editor. good luck 🤞
@upperarmhumor4 жыл бұрын
I used this technique as a crash effect in a test game I made connect.unity.com/mg/other/block-juke
@skodaskoda66336 жыл бұрын
how to choose color for explosion objects?
@learngamecreating13086 жыл бұрын
You can set color in createPiece() function, add this line; piece.GetComponent().material.color = new Color(255,0,0); //RGB red
@skodaskoda66336 жыл бұрын
Thank you Bro!!!
@kristianulrych60944 жыл бұрын
Is there a way how to make each different part of exploded cube colored?
@dubdub97474 жыл бұрын
Yes, when creating the cubes, you can access the Renderer for that cube and assign a material. Now you've just got to create the materials you want to use. There are a few ways of doing it, but I'd suggest creating a 'System.Random' object (which will generate random numbers, part of .NET library). You then create a new material, and set the color of the material to a new 'Color' object. In the constructor, generate three values between 0-1 for the new color. Ends up looking something like this: piece.GetComponent().material.color = new Color((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble()); Note: When creating the 'System.Random' object, make sure it's not inside the 'CreatePiece' method, it should be at the top of your script as a private variable, you can initialise it there as well.
@elnurdamirov5566 жыл бұрын
Hello bro.How can i change tag of the created pieces through script
@learngamecreating13085 жыл бұрын
Declare the tag in the tag manager, then //put this in createPiece function piece.tag = "TagName";
@aryan.puthran5 жыл бұрын
How do you make it so when you hit a trigger further away, you can see the cube fall and break?
@blastback275 жыл бұрын
one intuitive way is that you can make a sphere and put it part of the "exploding object" so a child of it and make that sphere as large as the range of where you want the trigger to start, uncheck the sphere meshes (so you cant see it) and make that sphere's collider a trigger and now do the same thing that he did, is just that within the code of the sphere make a trigger code like we see at the earlier part of the video when it says "onTriggerEnter" make that function for the sphere and make another script for the object that is exploding as he did, all you need to say in the code for the sphere is that when it is triggered, then call the function in the "exploding-object" code that is separate, to do so you just type FindObjectOfType()." the methods name"(); and this will activate the function within the code of the "exploding-object" code. not in quotation ofc. And if you wanna know what function he called check the same part and try to figure the rest out, which should be self-explanatory.
@blastback275 жыл бұрын
Or use if (Physics.CheckSphere(transform.position, sphereRaduis, LayerID)) when it returns true then it will run the code you put in, which is the same one as the onTriggerEnter stuff..
@aryan.puthran5 жыл бұрын
Ok! Thank you!
@equinox13465 жыл бұрын
How can i change the colors of the pieces?
@aborayan52686 жыл бұрын
How to destroy after a period?
@samduartec6 жыл бұрын
@Amine Kh that doesnt work because the object with the script is no longer active
@alphaspace11004 жыл бұрын
thx
@bittublastgamer2022 жыл бұрын
can you help my bosx is not exploding
@atakanbacak8281 Жыл бұрын
you forgot public float explosionForce = 50f; public float explosionRadius = 4f; public float explosionUpward = 0.4f;
@mrcryptographic48034 жыл бұрын
how can i have the piece destroyed after a certain time in this script?
@thewildreamer4 жыл бұрын
you can use Invoke("functionname",time by f); for example : Invoke("explosion",2f);
@mrcryptographic48034 жыл бұрын
@@thewildreamer i mean how can i destroy the piece after a time and not how can i spawn the explosion after a time. or did I not understand something?
@The_Mavrik5 жыл бұрын
Классный урок. Но почему у тебя всего 1 видео на канале???
@learngamecreating13085 жыл бұрын
Thank you, new content will be coming soon.
@Adul1k4 жыл бұрын
how do I change material of those small cubes ?
@dubdub97474 жыл бұрын
Get the 'Renderer' component for the cube, then select the material propery, and assign it to the desired material (for example, if you want it to be the same as the original cube, you want (gameObject.getComponent().material)
@aniketmeghani16275 жыл бұрын
i learn about make game how can i start???
@learngamecreating13085 жыл бұрын
You started already, keep going!
@adamhilali8064 жыл бұрын
why it doesn't work it really help me sure but it didn't work
@mateus10pras144 жыл бұрын
My Unity crashed at 02:22 and my computer is a i5 8400 + rtx 2070 super + 16 gb ram
@kumelogames6 жыл бұрын
how do you change color
@learngamecreating13086 жыл бұрын
//put these lines to createPiece function material = piece.GetComponent().material; material.color=Color.red;
@djukicdev5 жыл бұрын
@skipsbiceps assign public Material red; , then just use it wherever you need as piece.GetComponent().material = red; Dont forget to link mat in inspector tho
@Adul1k4 жыл бұрын
How can I destroy those cubes after like 2 seconds ?
@MamMam-zo1sm4 жыл бұрын
Destroy(Gameobject , time);
@LEARN-UNITY3D Жыл бұрын
Wow its working ! But i want to k ow how to destroy these cube pieces bcos it makes pollution in my game! Please if u can solve this
@manuelabarcacrespo8298 Жыл бұрын
Destroy(cube, time);
@mohsinnaseer41274 жыл бұрын
oh i copied from drive script by the way thanks for the video
@factsspace83266 жыл бұрын
You can slow down your speed and explain the code to us it would be so nice
@learngamecreating13086 жыл бұрын
thank you for your feedback. i explain everything in subtitles. Did you try it? I hope you like it.
@bonniedunlap23997 жыл бұрын
Bonnie Dunlap
@hanssarpei86876 жыл бұрын
How can I destroy this pieces?
@larcondos9096 жыл бұрын
In the section of code at the end of "createPiece", you can add another script that destroys those pieces after some condition (Say, 2 seconds, or on touch)
@learngamecreating13086 жыл бұрын
as Larcondos mention above; //just put this line to end of createPiece function Destroy(piece, 3); //3 means after 3 seconds, remove object from scene.
@afkfish43684 жыл бұрын
it is not working like the code it say that i need to fix it
@KamikazeSensei4 жыл бұрын
try changing the name for your script to "Explosion"
@oppenheimeroficial4 жыл бұрын
Same... function turns red... feels like he's just making the functions up