Explosive Damage and Force with Obstructions | Unity Tutorial

Опубликовано: 12 Октябрь 2024
на канале: LlamAcademy
7,303
227

Explosions are a powerful and fun effect to add into your game. In this tutorial we'll add point-and-click explosions to both apply damage, and knock back Rigidbodies in a scene. We'll also implement relatively simple method o determining if a wall is in the way of the explosion. If there is some obstruction, then we'll say the explosion won't affect the object on the other side.

Using a Rigidbody allows us to capitalize on Unity's physics engine to apply knock back force based on the explosion position and explosive force. We'll play with some different explosive force values to see the difference between values like 1,000 and 5,000 on some Rigidbody barrels.

I'll show how you can calculate the damage value with a linear falloff from the explosion point. You can follow the same math and apply a custom AnimationCurve if you would like to apply a more complex damage falloff curve.

👨‍💻 As always, all code from this video is available on GitHub: https://github.com/llamacademy/explos...

🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?sect...

🧡 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:
🌟 Patreon:   / llamacademy  
🌟 YouTube Member:    / @llamacademy   or click the Join button on any video
📚 Take my Unity ShaderGraph Course:
https://www.gamedev.tv/p/unity-shader...
👕 Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/
💸 Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4
💸 Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publishe... (affiliate)
💸 Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sal... (affiliate)

Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.

Chapters:
00:00 Introduction
01:21 Getting Unity Particle Pack
01:44 Scene Overview
02:20 ExplodeOnClick.cs
07:35 Setting up the Scene & Particles
08:15 Visualize the Explosions
08:45 Execute the Explosions
09:01 Execute STRONGER Explosions
09:31 Closing