- Home /
How do I enable a power up script on my player from another gameobject?
Im doing a 2D platformer game and it has power ups but not like jump boost or speed boost the power ups are like in super mario bros 3 like if you pick it up you can perform melee attacks or another one that allows you to shoot projectiles and I already created the scrips of the specific power ups and I put them into the player and they are disable by default and the player starts without them so now i want that when it picks up a power up it enables the scrip and allows perform the actions of the power up. This is the code I set to the power up for the player to pick it up` { private void OnTriggerEnter2D(Collider2D collision) { if(collision.tag == "Player") { GameObject player = player.GetComponent(enable = true);
}
}`
Answer by andylukito97 · May 11, 2020 at 05:23 AM
@ferxdie Can you post your full script again? It seems to be cut off. I'm gonna guess you're putting the OnTriggerEnterScript inside the powerup
if (collision.tag =="Player)
{
collision.GetComponent<SCRIPTNAME.cs>().enabled = true
}
Your answer
Follow this Question
Related Questions
spawn a powerup in 2D platformer c# 1 Answer
PowerUI == simple onclick event 1 Answer
Totalling powerup values 0 Answers
Using modulus when score climbs in odd integers. 2 Answers
Changing a Player's GameObject when damaged/powerup 0 Answers