- Home /
Question by
unity_DGnRuL9hfDuU9w · Jul 29, 2021 at 12:14 PM ·
androidscripting problemprefabbug
Prefab is spawned two times in a row
When this code is executed, the prefab is spawned twice in a row. Why? How to fix this bug?
void OnTriggerEnter()
{
randomNumber = Random.Range(0.0f, 5.5f);
Instantiate(Prefab, new Vector3(-0.04f, -1.07f, Counter), Quaternion.identity);
this.transform.position = new Vector3(Random.Range(-5.1f, 5.26f), 0.63f, Counter - randomNumber);
Counter += 30;
}
Comment
Comment this code out for a moment and temporarily replace it with:
void OnTriggerEnter ( Collider other )
{
Debug.Log( $"[{Time.time:0.00}] \"{this.name}\" :: OnTriggerEnter( {other.name} )" , other.gameObject );
}
My bet is that it will show you that there are 2 trigger collisions.