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
0
Question by philippstaib · Oct 12, 2017 at 05:37 PM · scripting problemscript.destroydestroy objectdestroygameobject

Script doesn't work anymore!

I made a game where you can pick up objects and drop them into a fire, and with a script they got destroyed then, but now it doesn't work anymore. I just saved it last time (when it worked) and now i started unity and nothing happens anymore when i drop something in the fire! Pls help!

Here's the script which should destroy the objects:

using UnityEngine;
using UnityEngine.SceneManagement;

public class Dropped : MonoBehaviour
{
public bool isBurning = false;
public float BurnedCount = 0;
public string leveltoload;
public GameObject BurnParticels;

 public void onTriggerEnter(Collider other)  
 {  
     if (other.CompareTag("Burnable"))
     {
         if (other.attachedRigidbody.isKinematic == false)
         {
             if (BurnedCount == 2)
             {
                 SceneManager.LoadSceneAsync(leveltoload);
                 Debug.Log("Burned three things");
             }
             else
             {
                 isBurning = true;
                 BurnedCount = BurnedCount + 1;
                 Destroy(other.gameObject);
             }
         }
     }
     if (other.CompareTag("Stone"))
     {
         if (other.attachedRigidbody.isKinematic == false)
         {                
                 isBurning = false;                 
                 Destroy(other.gameObject);               
         }
     }
 }
 private void Awake()
 {
     DontDestroyOnLoad(gameObject);
 }
 private void Update()
 {
     if (isBurning)
     {
         BurnParticels.SetActive(true);
     }
     else
     {
         BurnParticels.SetActive(false);
     }
 }

}

Comment
Add comment · Show 2
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 YoucefB · Oct 12, 2017 at 05:45 PM 0
Share

Check if your gameObjects have the tags assigned, maybe you forgot to save the scene or the prefabs if there is any.

avatar image philippstaib YoucefB · Oct 12, 2017 at 05:49 PM 0
Share

I checked it but all objects have the right tag, but thanks for your answer!

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by philippstaib · Oct 12, 2017 at 07:39 PM

I solved my problem now by coding a slightly different script and now it's working

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
1

Answer by toddisarockstar · Oct 12, 2017 at 06:25 PM

add these lines after the trigger:

  public void onTriggerEnter(Collider other)  
  {  print("my collision is working");
      if (other.CompareTag("Burnable"))
      {print("tags are correct");
 

if you see both messages in the console then it's a problem with your script or varibles it acceses.

if you see one message then it's a problem with your tags.

if you see nothing then its a problem with your colliders/rigidbodys.

Good luck!!!

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 philippstaib · Oct 12, 2017 at 07:37 PM 0
Share

I see nothing, but now i rewrote the script in another way, and now its working

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

129 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 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

Destroying Assests Not Permitted 1 Answer

Can you destroy an object using GetInstanceID? 0 Answers

How to make game object 1 able to destroy game object 2 if it was given some sort of power up? 0 Answers

Unity createNew Game Object after calling a Destroy() 1 Answer

How do I Destroy a Child after Instantiating it? 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