Test instance count problem
#1
Posted 11 September 2011 - 08:28 AM
I have made a test instance count in my controller objects step event to make it go on to the next round. it is all working fine except that for some reason sometimes it will not go to the next round after all the zombies are killed.
Any help?
#2
Posted 11 September 2011 - 08:32 AM
Edit - ah, yes, check what Nocturne suggests as well!
Thanks,
Richard
Edited by Richard, 11 September 2011 - 08:39 AM.
#3
Posted 11 September 2011 - 08:35 AM
I am making a zombie game where there is "rounds", it starts on round 1 and after you kill all the current zombies it will go to the next round and spawn more.
I have made a test instance count in my controller objects step event to make it go on to the next round. it is all working fine except that for some reason sometimes it will not go to the next round after all the zombies are killed.
Any help?
Run the game in debug mode and open the instance window, then check and see if all the zombies are really gone! Maybe one ends up outside the room or something?
#4
Posted 11 September 2011 - 08:38 AM
Can you show us the action blocks or GML code that you're using? The easiest way might be to copy and paste the object information, which you can find by clicking Show Information on the left hand side of the object properties window. We'd be pretty much guessing wildly without that bit more information!
Thanks,
Richard
if global.betweenrounds !=1
{
if !instance_exists(enemy)
{
alarm[0]=1
}
}There is a short break in-between rounds so I made a between rounds variable so that it will stop checking the instance count in-between rounds.
And alarm 0 contains the script to spawn more zombies and increase the round number.
#5
Posted 11 September 2011 - 08:42 AM
Thanks you are right, there is still one or two zombie instances.
I am making a zombie game where there is "rounds", it starts on round 1 and after you kill all the current zombies it will go to the next round and spawn more.
I have made a test instance count in my controller objects step event to make it go on to the next round. it is all working fine except that for some reason sometimes it will not go to the next round after all the zombies are killed.
Any help?
Run the game in debug mode and open the instance window, then check and see if all the zombies are really gone! Maybe one ends up outside the room or something?
Now I will need to think of something to stop them from staying out of the room.
#6
Posted 11 September 2011 - 08:45 AM

For some reason this isn't working, I cant think of any way why it shouldn't.
Any help?
#7
Posted 11 September 2011 - 08:47 AM
#8
Posted 11 September 2011 - 08:52 AM
I would use the outside room event but they start slightly outside the room so it would just kill all of them.If you want to check every step, set the alarm to 1, as 0 will not work. But there is also an "outside room" event that you can use...
I think why its not working is because there is multiple instances of enemy so it wouldn't know which x and y to use?
Is there a way to check the x and y of its-self?, maybe something like (self).x or (self).y ?
#9
Posted 11 September 2011 - 08:55 AM
Ah - that makes sense. if these action blocks are in the enemy object, you can just use x and y to make each instance check its own particular x and y coordinates. If you want to use the self keyword for clarity, self.x and self.y ought to work as well.I think why its not working is because there is multiple instances of enemy so it wouldn't know which x and y to use?
Is there a way to check the x and y of its-self?, maybe something like (self).x or (self).y ?
Richard
Edited by Richard, 11 September 2011 - 08:56 AM.
#10
Posted 11 September 2011 - 09:17 AM
Here is my script:
//Kill if outside room
if y > room_height
{
instance_destroy()
}
if x > room_width
{
instance_destroy()
}
Edited by ma37icws, 11 September 2011 - 09:18 AM.
#11
Posted 11 September 2011 - 09:37 AM
//Kill if outside room
if y > room_height
{
instance_destroy()
}
if x > room_width
{
instance_destroy()
}Do they always leave the room by going beyond the right hand edge or the bottom edge? What if their coordinates are less than 0 (or in other words, what if the objects are above the top of the room or to the left of the left hand edge of the room)?Richard
#12
Posted 11 September 2011 - 09:51 AM
Wow, thanks I never thought about that, I added another check to see if its x or y are lower than 0 and it is now working flawlessly.Do they always leave the room by going beyond the right hand edge or the bottom edge? What if their coordinates are less than 0 (or in other words, what if the objects are above the top of the room or to the left of the left hand edge of the room)?//Kill if outside room if y > room_height { instance_destroy() } if x > room_width { instance_destroy() }
Richard
#13
Posted 11 September 2011 - 01:00 PM
Haha - ain't this stuff fun?! Glad you got it working.Wow, thanks I never thought about that, I added another check to see if its x or y are lower than 0 and it is now working flawlessly.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











