Hello ,
I’m trying to make a rythm music game, where notes in shape of sphere will drop down on a table and once user hit the correct key(1 to 6) , I want the correct note to explode depends on which rail is the note , So my logic goes like this :
As you can see I have an invisible rigid body , so while the note is inside of it , if user hit the correct key , I wanted the note to explode
and my note Control script goes like this :
void Update () {
if (Input.GetKeyDown(activate))
{
if (score)
{
Debug.Log(gameObject.name);
Destroy(gameObject);
Instantiate(succBurst, transform.position, succBurst.rotation);
score = false;
}
}
}
void OnTriggerEnter(Collider other)
{
Debug.Log(other.gameObject.name);
if (other.gameObject.name == "FailedCol")
{
Destroy(gameObject);
Instantiate(failedBurst, transform.position, failedBurst.rotation);
}
if( (other.gameObject.name == "score1"))
{
//The Ballon is inside the scoring rigid body which is the invisible part on picture
score = true;
}
}
}
But it seems not to work properly , how to destroy the gameObject ( the note ) prefab Only when inside the rigid body? What is wrong with my code and what I have missed?
Thank you