# Enemy Interactions

What is the simplest way to do the following?

Create spawn points for mobs\enemys?
Get Enemies to interact, like chase & attack the player?
Is there a way to have Enemies wander aimlessly until a player comes close enough?

1 Like

Create spawn points for mobs\enemys

Depend if you want them to spawn randomly, or if you already know where you want them to spawn.
You can when you create an object, put the value of where you want the ennemies to spawn for exemple X 100 and Y 100, so you can use the create object function like â€ścreate ennemies X:100 Y:100â€ť
Or, if you want them to spawn where there is a spawn object, then you can change X : 100 by X : NameOfTheSpawnPointObect.X()
same for Y and they would spawn at the spawn point object

Get Enemies to interact, like chase & attack the player

Again, depend, if you want them to interact depend on the position of the ennemy and the player, so you can use the distance function

Enemies wander aimlessly until a player comes close enough

Yeah, using the distance function, like â€śdistance between ennemies and player is > 100 then wander aimlesslyâ€ť prntscr.com/ijvtp3

Most of those questions were previously asked by other people, pretty sure you can find answer by searching in the forum

For the random aim GD has a very useful action â€śRotate objectâ€ť, you can use this action with a random angle (expression: Random(360)) and an angular speed and GD will rotate the object smoothly to the given target angle, if you do it every X seconds the enemy will look around randomly.
The raycast condition has been merged, so you can already use it, if the player is close enough (as Jeje2201 suggests) launch a ray from the enemy position in the enemy looking direction and check for intersecion with the player, if there is an intersection the enemy can see the player so stop chasing and add a force in the player direction, or use the pathfinding behavior if there are obstacles

1 Like

Hi Gentâ€™s thanks for the advice. I will give it a go and report back.

Just on this - they will spawn to the edge of the viewport and wonder in. How would you go about creating the events to achieve this? I was originally going to have them created when the scene was created, but think now it would be better to have them enter a few seconds after, and then and varying intervals from then on. From there spawn point they would then be attracted to the player.

What events would you use to do this?