How do I create multiple killer bats

Get help using Construct 2

Post » Mon Sep 12, 2016 2:39 pm

Hi,

Using some pretty basic code to get a killer bat to MoveTo my Player, and it works, but it will only work for 1 bat. I have multiple copies of the bat on the screen but only the first, original bat will move. I'd like all Bats to do the same movement. Here's my code:

Image

Here's the Player in the Bat Cave:

Image

Any thoughts/suggestions greatly appreciated!

thanks,
M
B
7
S
1
Posts: 23
Reputation: 421

Post » Mon Sep 12, 2016 3:14 pm

This work well for me :
Image
Can you provide a .capx ?
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Mon Sep 12, 2016 3:53 pm

Nice, this works for me as well, thanks.

I changed the speed to 1 and they flock to the Player as he goes by. Also added Solid behaviour so the Player can bump against them.

Image

Wondering now how I can give each Bat a different speed. Would an Instance Variable be the right tact? Create a Speed variable... but how to specify each Bat with it's own speed.
B
7
S
1
Posts: 23
Reputation: 421

Post » Mon Sep 12, 2016 4:00 pm

Welcome to the wonders of "instance picking". Search for it in the forums, tutorials, and manual.. lots of stuff on it.

TL;DR... you have to find a way to tell construct2 to "pick" the bat instances individually so it knows which ones to act on. This can be done many ways.. I would think in your version it would be best to use the instance variable for speed and then set it "On Create" of each instance to a random number... or if you wanted more realistic bat action you could simpy have a randomizing event that runs in the back ground choosing a random instance of "bat" and changing its speed to a random value every X seconds...
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370

Post » Tue Sep 13, 2016 1:17 pm

Interesting, thanks for the info, I'll start digging around. Yes, like the idea of a random speed change every X seconds.
B
7
S
1
Posts: 23
Reputation: 421


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, rekjl and 13 guests