Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by lordofworldz · Oct 15, 2017 at 07:09 PM · particlessoundtutorial

Space Shooter Player Will Not Instantiate an Explosion After Getting Killed

I am a beginner to Unity and I am currently going through the Unity tutorial "Space Shooter" and am currently going through the adding hazards, enemies, etc portion. I found that through this process that it stopped Instantiating the explosion for the player and won't play the sound either. Hopefully I can get some help to fix this.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by MochiTo · Oct 15, 2017 at 08:26 PM

There are too many ways that could make your game not working... you should be more specific in you questions in the future. i'll write down some potential problems I can think of...

  1. haven't you accidentaly removed the tag "player" from your player?

  2. is your DestroyByContact script in the right place?

  3. is you destroyByContact script the same as it should be? as here at the bottom of the page: (scripting context)

  4. does your player have the right collider set? isn't the collider disabled in the Inspector by accident on your player prefab?

  5. is your player destroyed, but the explosion doesn't play? is the explosion still in the project? haven't you erased it by accident?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lordofworldz · Oct 22, 2017 at 04:10 AM 0
Share

Sorry for the late response, but the player tag is set,, the destroyByContact script is in all the right places, and the script matches up with the tutorials with the enemy code included. The explosion sound and VFX is still there. The colliders are also set properly as well, still no instantiation. Not sure what the problem might be. Sorry I didn't specify these details in my question.

avatar image lordofworldz · Oct 22, 2017 at 11:39 PM 0
Share

Also, the player does disappear.

avatar image
0

Answer by InvictusCo · Oct 15, 2017 at 08:58 PM

Could you post your code on here ( click the little button that says 101010 next to the paper clip) so that we can better see what your problem could be?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by lordofworldz · Oct 22, 2017 at 03:54 AM

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class DestoryByContact : MonoBehaviour
 {
     public GameObject explosion;
     public GameObject playerExplosion;
     public int scoreValue;
     private GameController gameController;
 
     void Start()
     {
         GameObject gameControllerObject = GameObject.FindWithTag("GameController");
         if (gameControllerObject != null)
         {
             gameController = gameControllerObject.GetComponent <GameController>();
         }
         if(gameController == null)
         {
              Debug.Log("Cannot find 'GameController' script.");
         }
     }
 
     void OnTriggerEnter(Collider other)
     {
         if (other.CompareTag ("Boundary") || other.CompareTag ("Enemy"))
         {
             return;
         }
 
         if (explosion != null)
         {
             Instantiate(explosion, transform.position, transform.rotation);
         }
 
         if (other.CompareTag ("Player"))
         {
             Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
             gameController.GameOver();
         }
 
         gameController.AddScore (scoreValue);
         Destroy(other.gameObject);
         Destroy(gameObject);
     } 
 }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by gwnguy · Oct 22, 2017 at 04:15 AM

I don't know if the mispelling of the class (DestoryByContact instead of DestroyByContact) (tory instead of troy) would cause a problem.

Are you getting any build/compile errors in the console.log?

Are you sure you haven't accidentally used/modified the code in the _Complete_Game directory?

And, as MochiTo says, confirm your tags ( GameController, Player, Enemy, Boundary. Existence, spelling AND punctuation)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lordofworldz · Oct 22, 2017 at 11:36 PM 0
Share

So, I fixed the misspelling of the class, and that caused the hazards to not be detected, and I have checked all of the tags. The spelling and punctuation doesn't seem incorrect either, other than the DestoryByContact class name. There are also no compiling issues. Would you like me to send the rest of the Scripts?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

80 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Adding footsteps sounds to the Adventure tutorial 2 Answers

Detect the start of a particle burst emission 0 Answers

Play sound from particle 1 Answer

Sound play in spot of particle collision 1 Answer

Randomizing sounds (on keypress)? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges