{"id":13524147,"url":"https://github.com/hiulit/Godot-3-2D-Destructible-Objects","last_synced_at":"2025-04-01T02:30:38.955Z","repository":{"id":37742428,"uuid":"195246671","full_name":"hiulit/Godot-3-2D-Destructible-Objects","owner":"hiulit","description":"A script that takes a sprite, divides it into blocks and makes them explode 💥!","archived":false,"fork":false,"pushed_at":"2021-02-15T15:39:53.000Z","size":2325,"stargazers_count":396,"open_issues_count":4,"forks_count":27,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-30T00:16:25.601Z","etag":null,"topics":["2d","destructible","godot-engine","objects"],"latest_commit_sha":null,"homepage":"","language":"GDScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiulit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"hiulit","ko_fi":"hiulit","custom":"https://www.paypal.me/hiulit"}},"created_at":"2019-07-04T13:26:00.000Z","updated_at":"2024-10-22T13:05:26.000Z","dependencies_parsed_at":"2022-08-24T16:01:52.040Z","dependency_job_id":null,"html_url":"https://github.com/hiulit/Godot-3-2D-Destructible-Objects","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FGodot-3-2D-Destructible-Objects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FGodot-3-2D-Destructible-Objects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FGodot-3-2D-Destructible-Objects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FGodot-3-2D-Destructible-Objects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiulit","download_url":"https://codeload.github.com/hiulit/Godot-3-2D-Destructible-Objects/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222693039,"owners_count":17024034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d","destructible","godot-engine","objects"],"created_at":"2024-08-01T06:01:07.504Z","updated_at":"2024-11-02T08:31:27.600Z","avatar_url":"https://github.com/hiulit.png","language":"GDScript","funding_links":["https://patreon.com/hiulit","https://ko-fi.com/hiulit","https://www.paypal.me/hiulit"],"categories":["Plugins and scripts"],"sub_categories":["3D"],"readme":"# Godot 3 2D Destructible Objects\n\nA script that takes a sprite, divides it into blocks and makes them explode 💥!\n\n![Godot-3-2D-Destructible-Objects](examples/Godot-3-2D-Destructible-Objects.gif)\n\n## Limitations\n\nRight now, the sprites must be squares or rectangles for this script to work properly.\n\n## Prerequisites\n\nEach destructible object must follow this structure and must be its own `Scene` file.\n\n```\nRigidBody2D\n├── Sprite\n└── CollisionShape2D\n    └── RectangleShape2D\n```\n\n## Usage\n\n* Create a `Node2D` that will contain all the destructibles objects (e.g. `destructible_objects`).\n* Add a `Node2D` as a child node of the prior `Node2D` (e.g. `destructible_object_01`).\n* Instance the `destructible_object` scene file.\n* Attach `explode_object.gd` to the destructible object as a `Script`.\n\n![Godot-3-2D-Destructible-Objects-Tree](examples/tree.png)\n\nThe reason for organizing it this way is because then you can add particles (`Partcicles2D` or `CPUParticles2D`), fake particles (like the ones provided with this project), hitboxes (`Area2D`) or whatever you feel like to the `Node2D` (e.g. `destructible_object_01`) holding the main `RigidBody2D` and you can then use this script to control those nodes.\n\nOf course, you can recreate that tree in GDSscript, with something like this:\n\n```\nvar node = Node2D.new()\nnode.name = \"destructible_container\"\nget_parent().add_child(node, true)\n\nvar rigid_body = RigidBody2D.new()\nrigid_body.name = \"destructible_object\"\n\nvar sprite = Sprite.new()\n# Set the sprite's texture, size, etc.\nsprite.texture = preload(\"res://path/to/texture.png\")\n...\n\nvar collision = CollisionShape2D.new()\ncollision.shape = RectangleShape2D.new()\ncollision.shape.extents = Vector2(..., ...)\n\nrigid_body.add_child(sprite, true)\nrigid_body.add_child(collision, true)\n\nvar script = preload(\"res://path/to/explode_object.gd\")\nrigid_body.set_script(script)\n\n# Here you can set the 'rigid_body' variables from the script.\nrigid_body.blocks_per_side = ...\nrigid_body.blocks_impulse = ...\n\nnode.add_child(rigid_body, true)\n```\n\n## Parameters\n\n![Godot-3-2D-Destructible-Objects-Parameters](examples/parameters.png)\n\n### Blocks Per Side\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `blocks_per_side` | `int` | The blocks per side. Minium `2`. Maximum `10` (for performance reasons). | `6` |\n\n **Example**: `4` block per side makes a total of `16` blocks.\n\n### Blocks Impulse\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `blocks_impulse` | `float` | The *force* of the blocks when they explode. | `600` |\n\n### Blocks Gravity Scale\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `blocks_gravity_scale` | `float` | The gravity of the blocks. | `10` |\n\n### Debris max time\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `debris_max_time` | `float` | The seconds it will pass until the blocks become `STATIC` or, if `remove_debris` is set to `true`, they dissapear. | `5` |\n\n### Remove debris\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `remove_debris` | `bool` | Controls whether the debris stays or disappears. If set to `true`, the debris will dissapear when `debris_max_time` is over. | `false` |\n\n### Collision layers\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `collision_layers` | `int` | The collision layers of the blocks. | `1` |\n\nSum all the values of the layers.\n\n**Example**: `Layer 1` value is `1`. `Layer 5` value is `16`. So `collision_layers` would be `17`.\n\n### Collision masks\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `collision_masks` | `int` | The collision masks of the blocks. | `1` |\n\nSum all the values of the layers.\n\n**Example**: `Layer 1` value is `1`. `Layer 5` value is `16`. So `collision_layers` would be `17`.\n\n### Collision one way\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `collision_one_way` | `bool` | Set `one_way_collision` for the blocks. | `false` |\n\n### Explosion delay\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `explosion_delay` | `bool` | Adds a delay of before setting `object.detonate` to `false`. | `false` |\n\nSometimes `object.detonate` is set to `false` so quickly that the explosion never happens. If this happens, try setting `explosion_delay` to `true`.\n\n### Fake explosions group\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `fake_explosions_group` | `String` |  Renames the group's name of the fake explosion particles. | `fake_explosion_particles` |\n\nThis project provides an extra script for creating [fake explosion particles](https://github.com/hiulit/Godot-3-2D-Fake-Explosion-Particles). That script uses a group name to be able to find the fake explosion particles more easily.\n\n### Randomize seed\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `randomize_seed` | `bool` |  Randomize the seed. | `false` |\n\n### Debug mode\n\n| Name | Type | Description | Default |\n| --- | --- | --- | --- |\n| `debug_mode` | `bool` |  Prints some debug data. | `false` |\n\n## Changelog\n\nSee [CHANGELOG](CHANGELOG.md).\n\n## Authors\n\n* Me 😛 [hiulit](https://github.com/hiulit).\n\n## Credits\n\nThanks to:\n\n* Airvikar - For this [Youtube video](https://www.youtube.com/watch?v=ExX7Qyldtfg) that is the code base for this script.\n* [Securas](https://twitter.com/Securas2010) - For all the [great games](https://securas.itch.io/) and [Twitch streams](https://www.twitch.tv/sec_ras/videos?filter=all\u0026sort=time) that give me lots of ideas, and particularly, the destructible objects one.\n* [Scott Lembcke](https://twitter.com/slembcke) - For letting me know about Voronoi regions (which aren't currently available) and helping me with adding more depth to the explosion (random collisions and z-index).\n\n\n## License\n\n[MIT License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiulit%2FGodot-3-2D-Destructible-Objects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiulit%2FGodot-3-2D-Destructible-Objects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiulit%2FGodot-3-2D-Destructible-Objects/lists"}