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.
I don't know why. I can't get your black object to do anything - not even a basic collision will work with it.
What I did do was:
- Delete the black enemy.
- Clone the pink enemy and made a new one - enemy 3
- Put that everywhere there had been a black enemy.
- Removed the events that I had given you from the global list - put them in frame 2.
- Changed them to work with the qualifier - bad apple - not the individual enemy (which is why I had to take it out of global events)
You could try that - it seemed to work.
Is there a reason you want that pixel by pixel loop movement? Because you could give your enemy just a normal movement like bouncing ball, select only left and right - put a block left / block right - when it collides with block left - face the other direction - and vice versa. No loops needed. Only where you have only 1 blocker you would need two - one for the left and one for the right. You can change their speed to whatever you want it to be as well.
I was just following this tutorial.
https://youtube.com/watch?v=XktQxCeuluo
There are a few glitches reported in the comments of the video - one of them being, things only worked if there was 1 enemy or enemy type.
It just seems like a very complicated way of achieving something - I thought it might be interfering with why the black character didn't work - but I don't really know - it's just a guess.
If you're happy with the way things are working, then keep it that way, but if your enemies are just walking left and right - then I'd go for something simpler.