Something I was wondering. I made enemies in my app shoot when the player character overlaps an invisible active object, but it’ll only shoot in the direction it’s facing. Any way to only make it shoot at the player object when it’s facing it?
Something I was wondering. I made enemies in my app shoot when the player character overlaps an invisible active object, but it’ll only shoot in the direction it’s facing. Any way to only make it shoot at the player object when it’s facing it?
If you are using the built in "Launch an object" then you can select "Launch in direction of..." and then pick the player object. It will then always shoot towards the player.
Test the position of the enemy relative to the player & its direction. Something like this:
y position of Enemy <= y position of player + 5 (They're on the same platform)
y.position of Enemy >= y position of player - 5 (They're on the same platform)
+
x position of Enemy >= x position of player - 100 (Enemy is to the left of the player and within range)
x position of Enemy <= x position of player (Enemy is to the left of the player)
+
Enemy direction = Right (Enemy can see the player)
= Then Shoot
For clarification, I insert all the X and Y statements in the same event where the player overlaps the trigger, right?
If the player overlaps the trigger - turn a flag on for the player - let's say flag 1
Then start a new event
If flag 1 of player is on
+ all the x, y & direction stuff
= then shoot
I tried that and it's not working. It's in the global events.
You just have the enemy direction set wrong - yours is opposite to what it should be.
Change it so the enemy is looking right.
I tried that. It doesn't work. I even added one so that there's one for looking both directions. That didn't work.
Attached is an example of how it would work - from both sides
Frame 1 - the enemy will shoot if the player is in range.
Frame 2 - the enemy will only shoot if the player is in range and the player is overlapping a trigger object.
I followed the example for the one without the trigger, and it works on the pink enemies, but for some reason, it won't work on the black ones despite me doing the same thing.