(Solved) Platformer. The problem with AI throwing bombs

Hello, colleagues!
I created an enemy, he will throw bombs at the player.
When a player is detected (using Sprite), he must throw a bomb at the place where the player was. But I do not know how to do it(

  1. How to get the values of the player’s position so that the enemy throws a bomb there. (The problem is that you need to get the values and throw the bomb there, even if the player is no longer in that place)
  2. The bomb ignores the platforms while flying to the place where the player was. But reaching this place, the bomb falls on the platform.

How do I do this?

  1. Whenever your player is detected and before the bomb is thrown, you can put the x and y position of your player-sprite in two variables. You can use these two variables for determining the position your bomb is being thrown. Since you want your bombs to detonate on the platform, you want to set a point at the foot of your sprite and use this point as reference for the x and y position. It would look like:

  2. You can use the values of the two variables as reference for the bomb to detonate (if that’s what you mean by “the bomb falls on the platform”). Something like:
    If that becomes to tedious because you have to consider too many positions, you could also just create a tiny invisible collider-sprite at the position and use this sprite for a collision with your bomb (after which you would let the bomb explode and erase the collider sprite).

1 Like

Thank you, colleague)
I added this:
If the bomb stops in the air, then the “platformer” behavior is activated. Then the bomb falls.

1 Like