- Home /
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);
     }
 }
}
Check if your gameObjects have the tags assigned, maybe you forgot to save the scene or the prefabs if there is any.
I checked it but all objects have the right tag, but thanks for your 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
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!!!
I see nothing, but now i rewrote the script in another way, and now its working
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                