FPS Full Game Tutorial | Unity | Part 5 - Shooting at Bottles

Mike's Code
5 Mar 202304:41

Summary

TLDRIn this episode, the tutorial focuses on adding destructible glass bottles to a Unity FPS game. The process involves importing a beer bottle model from Blender, adjusting its scale and adding necessary colliders and rigid bodies for physics interactions. A script is then created to trigger an explosion effect when the bottle is shot, with parts flying off due to the deactivation of their kinematic property. The tutorial also explains how to set up a prefabricated beer bottle with a glass material. The episode concludes with an exciting demonstration of shooting and exploding the bottles, setting the stage for more advanced effects in future episodes.

Takeaways

  • 😀 Create a new folder named 'Models' to store your imported assets for organization.
  • 😀 Import a destructible beer bottle model from Blender, sliced into parts for the explosion effect.
  • 😀 Rename the parts of the bottle (e.g., Part1, Part2) to better manage them in Unity.
  • 😀 Scale down the beer bottle model upon import, as it's typically too large for the scene.
  • 😀 Add a box collider to the main beer bottle model to ensure it sits properly on surfaces.
  • 😀 For destructible effects, add mesh colliders to all parts of the beer bottle and enable the 'Convex' option.
  • 😀 Attach a rigid body to each bottle part, setting 'Is Kinematic' to true to prevent movement before the explosion.
  • 😀 Write a script for the beer bottle with a `Shatter` method that disables 'Is Kinematic' to trigger the explosion effect.
  • 😀 Modify the bullet script to interact with the beer bottle, causing the shatter effect when hit without destroying the bullet.
  • 😀 Create a custom tag (e.g., 'Beer') to identify the beer bottle model and apply it for easy detection during interactions.
  • 😀 Create a prefab from the beer bottle model, ensuring you can reuse it throughout the scene without re-importing the assets.
  • 😀 Design a new material called 'BottleGlass' to make the bottle look shiny and glass-like by adjusting metallic and smoothness properties.
  • 😀 Test the effect in Unity by positioning bottles in the scene and shooting at them to see the shattering behavior in action.
  • 😀 This tutorial focuses on destructible objects in Unity, offering useful insights for future interactive and explosive effects in games.

Q & A

  • What is the purpose of creating a 'Models' folder in Unity?

    -The 'Models' folder is created to organize and store the imported beer bottle model, which will be used in the scene for the explodable effect.

  • Why do we need to scale down the beer bottle model after importing it into Unity?

    -The beer bottle model is typically too large when imported into Unity, so scaling it down ensures that it fits appropriately within the game world.

  • What is the purpose of adding a Box Collider to the beer bottle?

    -The Box Collider is added to the beer bottle to allow it to interact properly with other objects in the scene, preventing it from falling through the ground or other surfaces.

  • Why is it important to add Mesh Colliders and enable the 'Convex' option for each part of the bottle?

    -Adding Mesh Colliders to each part of the bottle ensures that the individual pieces can physically interact with the environment. Enabling the 'Convex' option allows the colliders to function properly when dealing with complex shapes like the broken pieces of the bottle.

  • What does the 'Is Kinematic' property do, and why is it initially set to 'true' for the bottle parts?

    -'Is Kinematic' set to 'true' means that the parts of the bottle are not affected by physics and will stay in place. This is necessary initially to prevent the parts from moving before the explosion effect is triggered.

  • What is the role of the 'ShatterOrExplode' method in the BeerBottle script?

    -The 'ShatterOrExplode' method in the BeerBottle script loops through all parts of the bottle and sets their 'Is Kinematic' property to 'false'. This allows the bottle parts to fly off and create the explosion effect when triggered.

  • How does the bullet script detect when it hits a beer bottle and trigger the explosion effect?

    -The bullet script is modified to check if the bullet collides with a beer bottle. If it does, it calls the 'ShatterOrExplode' method, causing the parts of the bottle to become non-kinematic and explode.

  • Why do we tag the beer bottle as 'Beer' in Unity, and how does this help in the game?

    -Tagging the beer bottle as 'Beer' allows Unity to easily identify and differentiate it from other objects in the scene, making it easier to detect collisions and apply the shatter effect when the bullet hits the bottle.

  • What effect does the 'BottleGlass' material have on the beer bottle, and why is it used?

    -The 'BottleGlass' material gives the beer bottle a realistic appearance by setting it to a green color, increasing the metallic map to 1, and adjusting the smoothness. This creates a shiny, glass-like effect, making the bottle look more lifelike.

  • Why is it necessary to create a prefab for the beer bottle and how does it affect the project?

    -Creating a prefab for the beer bottle allows you to easily reuse the same bottle model throughout the scene, maintaining consistency and making it simpler to manage instances of the object. Prefabs also allow changes to be applied globally to all instances.

Outlines

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Mindmap

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Keywords

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Highlights

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن

Transcripts

plate

هذا القسم متوفر فقط للمشتركين. يرجى الترقية للوصول إلى هذه الميزة.

قم بالترقية الآن
Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
Unity TutorialFPS GameDestructible ObjectsGlass BottleExplosion EffectGame DevelopmentUnity 3DBullet InteractionBlender ModelRigidBody PhysicsSatisfying Gameplay
هل تحتاج إلى تلخيص باللغة الإنجليزية؟