How do I stop my enemy in range of the player?

Get help using Construct 2

Post » Sun May 25, 2014 12:11 pm

Hi,
I'm using a turret behaviour on my enemies to have them detect the player, turn to him and (on Turret shoot) resolve a path towards him.
Now I want them to stop at a certain distance from the player. So far I've been using a second turret behaviour, but this has a lot of side effects that I need to fix and is not ideal.
The easiest way I figure is using a dedicated collision check to fake a distance check in order to disable the approach behaviour. But I don't see an elegant way of assigning each enemy a sprite of type-depedant sizes, other than a seperate loop to place a radius sprite on each enemy each tick.
Any suggestions how best to go about a radius check per enemy?
B
15
S
7
Posts: 243
Reputation: 2,063

Post » Sun May 25, 2014 7:02 pm

You could use the "System:pick by comparison" condition with the distance() equation and an enemy "range" instance variable.

Ex.
System: pick Enemy by comparison distance(enemy.X, enemy.Y, player.X, player.Y) < enemy.range
--- enemy stop
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Sun May 25, 2014 7:13 pm

2D Game GUI Designer
B
12
S
4
G
3
Posts: 130
Reputation: 3,778

Post » Mon May 26, 2014 8:31 pm

the expression is of course a good idea, not really aware of all the methods C2 provides there.

now i'm trying to sort this in a wanna-be state machine, but somehow I still can't get my enemy to stop in range.

statesMech.PNG


why is the pathfinding behaviour not stoppable by either 'stop' nor 'disabeling' the behaviour?
You do not have the required permissions to view the files attached to this post.
B
15
S
7
Posts: 243
Reputation: 2,063


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests