My problem is simple. When my Player dies I Instantiate new button which allows me to respawn my player, but my Button doesn’t appear to Canvas as a child. Does anyone know the simpliest solution? Thank you in advance
Without seeing what your script looks like, it looks like it’s just instantiating a new button without a parent.
void OnTriggerEnter2D(Collider2D other)
{
Destroy(gameObject);
Vector3 explosionPosition = new Vector3(rigidbody.position.x, rigidbody.position.y, 0.0f);
Instantiate(explosion, explosionPosition, Quaternion.identity);
Vector3 finalScorePosition = new Vector3(22,139,0);
finalText.text = "Your final score: " + Score;
Vector3 respawnButtonPosition = new Vector3(28,33,0);
Instantiate(respawnButton, respawnButtonPosition, Quaternion.identity);
textScore.text = "";
}
That’s right. I need to know how to instantiate exactly as a child to a parent.
You need a reference to your canves and instantiate lets you declare a parent target as a parameter Unity - Scripting API: Object.Instantiate
However, that being said, you’d probably be better off having the button in the scene and just having it start inactive and turn it on when you need it to show up.
Thank you very much