Creating Super Power

I’m just hoping someone can steer me in the right direction . What I’m trying to do is have special pick up that once my player enters the trigger he gain special powers for a limited time … for example red will give him super speed and double jump, green munipulates his size so he can go into narrow areas , blue makes him able to stick to walls … yellow would b immortality like superMario star power … so on and so forth.

If you’ve created a player that is already controllable, then you must’ve set certain values on it, such as speed, and jump height. If you already have the script that allows the player to collect the ‘powerup’ for a certain amount of time, allow that power up to access the Player’s script, and modify the speed values, to where they will be reverted when time runs out. Things like double jump will be slightly more complicated, since you will have to code in the feature first, and then can unlock it through a boolean value when the powerup is collected. It took me a while to recode Unity’s FPC to double jump when I first began, but it should be relatively simpler for 2D. To change his size, just modify his transform. If the player has a health value, you can disable this to make him immortal.

For implementing the power-ups, I would probably use the player controller script. For the super speed and double jump, maybe try something like this:

public float speed; //You probably already have this in your script in some form or another, so feel free to discard this line if need be.
public int jumpsAllowedOffGround;
public float speedPowerupMultiplier;

public void onRedActivated() {
	jumpsAllowedOffGround = 2;
	speed = speed * speedPowerupMultiplier;
}

public void onRedDeactivated() {
	jumpsAllowedOffGround = 1;
	speed = speed * speedPowerupMultiplier;
}

For changing the size, this might be helpful:

public float smallerScaleX; //This is the scale of the character, just like you would use in the editor
public float smallerScaleY;
public float smallerScaleZ;

public float normalScaleX;
public float normalScaleY;
public float normalScaleZ;

public void onGreenActivated() {
	transform.localScale = new Vector3 (smallerScaleX, smallerScaleY, smallerScaleZ); // This scales it like you would expect. It requires a Vector3 as it needs x, y and z;
}

public void onGreenDeactivated() {
	transform.localScale = new Vector3 (normalScaleX, normalScaleY, normalScaleZ);
}

For wall climbing it would be best to see a dedicated post on the Unity Answers (try here), and for immortality, you would just need to pass some sort of boolean declaring if a player can die or not when hitting and enemy or something:

public bool immortal;

public void onYellowActivated() {
	immortal = true;
}

public void onYellowDeactivated() {
	immortal = false;
}

public void onPlayerShouldDie() {
	if (immortal == false) {
		//kill the player or something
	}
}

Remember that the variables in all the above code are public, and therefore can be assigned in the editor (make sure you don’t leave them at 0). All the best and good luck with your game :slight_smile: