- Home /
Question by
Supahsawnik99 · Aug 03, 2020 at 05:13 PM ·
unity 2dprefabschild object
How do I spawn a prefab object as a child object to the player?
Hello, I was wondering if anyone would be able to help me out with a problem with my project.
Basically, I want to add a Shield power-up to my game, and to do that, the player must shoot and destroy the item with the "Shield" tag. That part is working. However, I need the Shield item in my prefabs to be attached to the Player as a child, like this.
But, when I test it out in the game, and I destroy the Shield item, nothing happens. Here is the code I used to try and get it working.
What I'm asking is, is there an alternate way to achieve the effect I'm looking for when I need it to?
if (other.tag == "Shield")
{
//Instantiate(playerShield, Player.transform);
Instantiate(playerShield, other.transform.position, other.transform.rotation);
}
untitled.png
(5.4 kB)
Comment