One shot kill many monsters

For questions about using Classic.

Post » Thu Jan 29, 2009 6:03 pm

[quote="deadeye":1ed8d991]It's because your bullet is big enough to overlap more than one monster at a time, so it's possible to trigger "On collision" for more than one monster before it disappears off-screen.

Add a "For each monster" loop at the beginning of your bullet-collision event, that will take care of it.

But really... you're doing so many odd things in the game I think you should probably go through the Ghost Shooter tutorial first. You're moving your bullet manually, and a) you don't need to, because there is a Bullet Behavior, and b) you're not using TimeDelta to move it (or your monsters, for that matter), so it will run differently on different computers. Whenever you move something manually you should always use TimeDelta.

Also, if you switch to Bullet Behavior for your bullets, you can spawn them and destroy them instead of using just one bullet object and setting it's position off-screen when you don't need it.[/quote:1ed8d991]

Yes, my shot touches two monsters.

But I want to only one death.

In c++ I wrote...

[code:1ed8d991]for(int i=0 ; i<monstersAmount ; i++)
{
if(bullet.collision(monster[i]) && bullet.life == 1)
{
monster[i].destroy();
bullet.life = 0;
}
}[/code:1ed8d991]

...and a one monster that has been destroyed.

How to destroy an object instead of two?

Screenplay:
[code:1ed8d991]1. shot hits two monsters
2. first monster dies
3. shot is destroyed
4. second monster did not die, because there is no longer a shot[/code:1ed8d991]
B
2
G
3
Posts: 27
Reputation: 904

Post » Thu Jan 29, 2009 10:19 pm

+Pick a random monster
+ On collision between monster and bullet
> destroy monster
> destroy bullet

---

'Pick' means it selects a random monster, then it checks if it is colliding with the bullet... it will always pick ONE monster, so only THAT monster will be destroyed together with the bullet.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Jan 29, 2009 10:32 pm

[quote="Mipey":hybk218p]+Pick nearest monster
+ On collision between monster and bullet
> destroy monster
> destroy bullet

---

'Pick' means it selects a random monster, then it checks if it is colliding with the bullet... it will always pick ONE monster, so only THAT monster will be destroyed together with the bullet.[/quote:hybk218p]
Becouse why not make it simple?
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Fri Jan 30, 2009 1:33 am

[quote="maciek":3vduys75]How to destroy an object instead of two?[/quote:3vduys75]

Read the rest of my post:

[quote="deadeye":3vduys75]Add a "For each monster" loop at the beginning of your bullet-collision event, that will take care of it.[/quote:3vduys75]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 30, 2009 3:03 am

[quote="deadeye":20o5vwfy][quote="maciek":20o5vwfy]How to destroy an object instead of two?[/quote:20o5vwfy]

Read the rest of my post:

[quote="deadeye":20o5vwfy]Add a "For each monster" loop at the beginning of your bullet-collision event, that will take care of it.[/quote:20o5vwfy][/quote:20o5vwfy]

I tried.
Do not work.
Are you sure?

I checked repeatedly.

You can give an example?
B
2
G
3
Posts: 27
Reputation: 904

Post » Fri Jan 30, 2009 4:13 am

[quote="maciek":e75tcm1i]Are you sure?[/quote:e75tcm1i]

Yes:

http://willhostforfood.com/files3/9185517/mountain.cap
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 30, 2009 2:06 pm

[quote="deadeye":3v2mx2mk][quote="maciek":3v2mx2mk]Are you sure?[/quote:3v2mx2mk]

Yes:

http://willhostforfood.com/files3/9185517/mountain.cap[/quote:3v2mx2mk]

Check for updates.

Download updates, and send the file again, thanks.
B
2
G
3
Posts: 27
Reputation: 904

Post » Mon Feb 02, 2009 2:52 am

Ok, my mistake. :mrgreen:

deadeye, thanks. :)
B
2
G
3
Posts: 27
Reputation: 904

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests