Need Help Creating a Shield Script

So I tried making a shield which seemed pretty simple but I kept running into a problem with the Shield not syncing up with the character and just having the shield not being able to be put away and just spawning alot of shields i need help to make the shield appear only when the button is pressed down and attached to the character i’ll show you the script I have right now for this please respond soon!

if (Input.GetKeyDown(Shield))
{
GameObject Shield = (GameObject)Instantiate(shield);
Shield.transform.localScale = transform.localScale;
Shield.transform.parent = Player.transform;
}

Rather than instantiating the shield when you want to “activate” it, perhaps you should have it on always, but simply de-activate the game object, instead when you want it off. :slight_smile:

That should solve most of your issues. I’m not sure what you meant about “not syncing up with the player”.

1 Like