Hi guys, I have to spawn enemies on the right and left of the scene.
Once created, enemies should automatically go in the direction of the Player.
How can I do? What are the steps?
it’s the first time I’ve tried to do this and I don’t really know where to start.
under common actions for all objects and then under movement click add a force to move toward an object. Then select your enemy as the first object and the player as the target and set the speed to whatever you want. for spawning the enemies add an at the beginning the scene condition and as the action add Start or reset a scene timer and enter a name inside of quotation marks in the box. Then make a new event and for the condition add value of a scene timer and put in the delay between the enemies spawning and the name you put in for the timer previously. Then, in the actions put create an object. Then select your enemy in the “Object to create” box. For the x position put zero (if you want the enemy to spawn just off screen then subtract their width). For the y position put Random(SceneWindowHeight()). Now add another action in this event. Add Start or reset a scene timer and type in the name again. Now, to make them spawn on the right side of the screen, copy and paste the event we were just working on. In the copy, re-open the Create an object action and replace the current x position with SceneWindowWidth(). Now if you run the game you should have enemies spawning at the selected delay from both sides of the screen moving towards your player. Hope this helped
You can use add force towards position command
Thank you so much!!! I have to try it soon
I tried to put the enemy that follows the player and it works very well!
But in your opinion, how can you change the direction of the enemy too?
Now the enemy chases the player, but if the player goes to the enemy and overtakes him, the enemy walks backwards in moonwalk style, chasing him.
In a condition put compare x position of an object. in the first box select your enemy then for the test sign put the less than symbol(<). Then put insertplayernamehere.X() . In the actions for this event put Flip the object horizontally. In the first box select your enemy then select no. Now copy and past the event. In the compare x position condition change the test sign to greater than. Now in the flip action change flipping to yes. now the enemy should turn towards the player
This is hard to explain thing with a lot of posibilites:
How do I spawn in my games:
Sprite 1 = Zone - (Object Variable) obj_var_collided = 0
Sprite 2 = obj_spawn_here → (Object Variable) obj_var_enemy_name = “name_of_enemy”
Sprite 3 - My player
if player collide zone and zone = 0
foreach obj_spawn_here collision with zone
Do create object = obj_var_enemy_name
set obj_var_collided = 1
If a zone is in collision with 3 obj_spawn_here the 3 enemies of the selected name will be created.
The spawn works too!! Thank you!!