How do I make enemies shoot instead of just follow you

Get help using Construct 2

Post » Sat Jun 20, 2015 4:01 am

Message: SexyBabyJesusZ is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
How can I make enemies try to shoot at the player, than just try to follow him? I can't seem to get the bullet sprite to spawn in, and it wont shoot.

Screenshot of the event sheet:
B
3
Posts: 9
Reputation: 199

Post » Sat Jun 20, 2015 4:02 am

Welp, can't post screenshots because of the stupid rule they have in place.

I'll write everything here:

System - Every tick - Player - Set angle toward (Mouse.X("game"),Mouse.Y("game")
Mouse - Left button is down - Player - Spawn Bullet on layer "game:(image point "shootpoint"
Bullet - On collision with enemy - Enemy - subtract 10 health
- Bullet - Destroy
Enemy - Health < 0 - Enemy - Destroy
...Just some movement for player...
Enemy - Has LOS to Player - Enemy set angle toward Player.X, Player.Y)
- Enemy - Set Bullet speed to 100
Enemy - X has LOS to palyer
Player - On collision with Bullet2 0 Player - Subtract 10 from health
Sprite (Health bar) - Set width to Player.Health
Sprite - is on screen
Player - Health = 0 - Player - set opacity to 0
System - Go to layout 2 (Death screen)
Bullet 2 - on collision with player - Player - subtract 20 health
sprite - set width to Player.Health
Enemy - Has LOS to player - Bullet 2 - set angle towards Player.X,Player.Y
Bullet 2 - Set Bullet speed to 100
Bullet 2 - set bullet enabled
B
3
Posts: 9
Reputation: 199

Post » Sat Jun 20, 2015 5:24 am

What you can do, which is rather simple, is tell your enemy to "Spawn" your bullet object. You can use the Every X seconds to control the frequency of the bullets created.
Its pretty much the same way as your player script except without the input controls.
B
21
S
5
Posts: 44
Reputation: 1,644

Post » Sat Jun 20, 2015 1:11 pm

As for the layer, and the Image point, what should those values be? And, I can't seem to find a way to keep the health bar at the top right corner wherever the player moves.
B
3
Posts: 9
Reputation: 199

Post » Sat Jun 20, 2015 2:46 pm

layer "HUD" parallax (0,0) and your health bar stays where you want
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sat Jun 20, 2015 4:05 pm

Ok, I got it working. But then I added a new background, and I can see it in the layout screen, but when I play it it's not on screen,
B
3
Posts: 9
Reputation: 199

Post » Sat Jun 20, 2015 7:27 pm

Make sure your hud screen is on the top most layer, it should allow you to see it now.
B
13
S
5
G
1
Posts: 119
Reputation: 2,292

Post » Sat Jun 20, 2015 8:57 pm

It is, but it doesn't show up in game for some reason
B
3
Posts: 9
Reputation: 199

Post » Sun Jun 21, 2015 3:28 pm

give enemies the turret behavior and use the "On Shoot" command. Make them spawn their bullet, it should automatically fire in whatever direction the enemy is facing
B
7
S
1
Posts: 20
Reputation: 585


Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish, Yahoo [Bot] and 14 guests