Hi, Tom. How do I implement destroying enemies using P+ dashing state?
Viewing post in Let's Build a Platformer! comments
Hey there,
There are a couple of ways to do this.
You could set a global variable to true at the start of the dash state and then false at the end using the 'Attach Script to P+ State' event. Then check that variable in the enemies 'On Hit' script. If true, then destroy the enemy, else player is hurt.
There is also the 'Store P+ State in Variable' event in the P+ plugin. That checks what state the player is in and stores it in a variable. You could use that event within the enemies 'On Hit' script. Directly after that event, you check if the stored variable is equal to the dashes value (the 'Store P+ State in Variable' event will tell what value is associated to what state) and run a script if true, else player is hurt. If you need to check for multiple states at once, you can use an 'If Math Expression' event.
I'll add this kind of functionality to the game in an upcoming lesson, in fact. I'll be adding little mini-missions to some of the houses in Peas home town to explore these kinds of mechanics and discuss how to effectively tutorialize mechanics in games.