Guys help me >.<

How to enemy following player

3 Likes

I have a sprite that does that in one of my games. Here’s how I made it work…

I used a timer so that the enemy checks for the player’s position intermittently, instead of constantly. I think an “always” trigger should make it work constantly. I used the timer because I wanted to give my player character more time to escape. :slightly_smiling_face:

Connect those to extractors (found in the properties menu) - one for both X and Y, if you want the enemy to follow you both side to side as well as up and down. Set both extractors to extract from the other object, then select your player character as the object.

What this does is tells the enemy to extract your player’s coordinates on the map. :slightly_smiling_face:

Then you will want to connect a “point at” command (found in the components menu). Connect the “other X” to the x input on the PointAt, and the “other Y” to the y input on the PointAt. This tells the enemy to “go to” that location. Set a velocity for the enemy, and then it will move at that speed towards your player.

Hope that helps. :slightly_smiling_face:

4 Likes

@TGW’s example is a nice straightforward approach. If you want other ideas look at the examples here: Flowlab Game Creator - Flowlab Game Examples and here: Flowlab Game Creator - Exploring Flowlab

4 Likes

Thank all, And TGW can you screenshot how to spawn monster eggs with 1 level in behavior

2 Likes

Do you mean in only one level?

yes mellojello :smile: … t

2 Likes

Ok then :upside_down_face:

You can adjust the filter to match the level number of the level and you can adjust the length of the timer but this should work :upside_down_face:

This basically checks the number of the level that is currently being played. If it matches, then it starts the timer, which will always repeat. Every time this timer ends, the egg will be spawned. If you don’t want a timer, you can just have the filter spawn the egg directly :upside_down_face:

3 Likes

you are very helpful, And sorry if I ask too much, I’m still a beginner

3 Likes

That’s fine, people on this forum will always be here to help :upside_down_face:

3 Likes

:disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved: :disappointed_relieved:

3 Likes

Hei TGW I I tried what you screenshot didn’t work :thinking:

2 Likes

and mellojello but not work to

Do you have a link to your game, or a screenshot of your behaviors? There could be something else interfering with your enemy’s movements.

1 Like

wait ok
:grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning: :grinning:

[quote=“TGW, post:13, topic:33154, full:true”]
Do you have a link to your game, or a screenshot

1 Like

Screenshot 2021-07-19 144726 and that how its

1 Like

It looks like you have your enemy set to rotate, which for a 2D platformer, you probably don’t want rotation unless your character is a ball. Your character should only need X axis movements, and toggle flip when hitting a wall. You probably don’t need the Y axis at all.

1 Like

so what should i do :thinking:

1 Like

Give me a minute, I’m working on an example that should do what you’re trying to do (hopefully).

Actually, cancel that. It’s hard to get it to work right in a 2D platformer using my method. But I did find this instead.

Flowlab Game Creator - Follow Example

NOT MY WORK. It was created by one of the most talented Flowlab users, @JR01 so you know it’s good (it works really well, should be perfect for your game). All credit goes to JR. I only get credit for finding the link. :slightly_smiling_face:

2 Likes

I also have this example where you put the picture of the monster on top of the rotating object that’s chasing the player (that’s invisible). Flowlab Game Creator - Chase Example

I plan to remake this example later, but this and the follow example TGW showed are some ideas to use. What exactly are you trying to do? More details on what you want to do would help. :slight_smile:

3 Likes