Enemy Hover When Player Is Hidden

Hi,

For a 2D platformer, I’d like to have a “hide” feature similar to the following:

  • The player is chased by an enemy when they are detected by the enemy’s proximity checker (I have this)
  • Have the ability to set the player’s alpha is set to 0 to hide in an object (I have this)
  • Make the enemy not move (just “hover”) when the player’s alpha is set to 0 (what I need)

The way the enemy moves is by using proximity to detect the player then get the player’s x and y to follow them.

I’d appreciate any input! Unfortunately while the game is still in development I can’t share it, but I attached a screenshot of the enemy movement.

2 Likes

You can make it so that when the player’s alpha is zero, using either a message from the player or the extractor, the enemy stops moving.

2 Likes

Thanks for your help! Would that be in with the proximity checking behavior, or in a separate “always” to check the player’s alpha? How would I structure the behavior (if alpha value, then no movement on x or y axis)?

1 Like

Look, in the player object, make it so when it’s alpha is 0, it sends a message to the enemy and stops it.

1 Like

That makes sense – although I have an “always” for checking the proximity to the player. How can I have two “cases” for if the message comes in or otherwise? If I keep the always it ignores the message.

I got it to work – thank you!

1 Like