patrolling and shooting enemy

Get help using Construct 2

Post » Sat Sep 17, 2011 12:18 pm

hello

i created an enemy that is walking left and right and should fire a projectile if the player gets too close.

the movement of the enemy is controlled by a boolean called "w_left", that toggles if the enemy collides with a sprite called "turn". as long as w_left is true the enemy walkes to the left and if it is false he walkes to the right.
if the enemy is walking to the left (w_left is true) and the player is less than 200px away (enemy.x <= player.x + 200) it should fire a shot. i did the same accordingly for the other side.

if the enemy is walking towards the player everything works smoothly, but if the enemy turns around and faces the other direction it is shooting constanly.

i tried to cover all possible states that could occur but i was not able to figure it out. this drives me mad, i hope someone can help me.

game
file

controls are:
left - A
right - D
jump - L

the black thing around the enemy should symbolise the range.

thanks in advancePete2011-09-17 12:20:46
B
11
S
3
G
2
Posts: 15
Reputation: 1,569

Post » Sat Sep 17, 2011 12:30 pm

Event8
add another condition
Compare avgn.X => avgn.x <= e_zombie.x

Event9
add another condition
Compare avgn.X => avgn.x >= e_zombie.x

Seems that the logic works as intended from there.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sat Sep 17, 2011 12:38 pm

thank you very much
B
11
S
3
G
2
Posts: 15
Reputation: 1,569

Post » Tue Feb 28, 2012 1:02 am

Thanks for this Pete! I tried three different methods for back-and-forth enemy movement. Your 'boolean' approached worked perfect!Dominic2012-03-15 20:28:36
B
25
S
5
G
6
Posts: 18
Reputation: 5,154

Post » Sat Aug 11, 2012 1:33 pm

File Not Found...
B
3
Posts: 3
Reputation: 331

Post » Tue Apr 30, 2013 7:18 pm

both files not found
B
3
Posts: 30
Reputation: 660


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jul, TELLES0808 and 20 guests