I want to implement a power up system into my 2d platformer but instead of the power ups just offering extra speed or a health replenishment my power ups will be like totally different characters with different sprites, sizes and abilities (e.g inverting gravity, shooting lasers, climbing on walls, etc.).
At the minute i'm just going to try getting the player to change to a different power up. Does anyone have any idea how I could do this? I'm thinking destroy the player when they come in contact with the power up and then spawn a new player, with the new ability, in it's place but i'm not sure.
I would say the most effective way is using an event system;
PowerUpScriptIdea: powerup will have a OnTriggerEnter() method inside of it, and if an object collides, this method will check if its the player, if it is, hide/destroy the powerup, but before doing so, send a message/event to the player that a powerup has been collected.
PlayerScriptIdea: will have powerup() method corresponding to event powerup, once that event is called, player will have speed+=200, or jump+=10, etc.
If you want to save memory, instead of destroying the powerup, hide the meshrenender of the powerup, and just move it to the next place it appears in, etc, so that way you can reuse the same powerup objects.