Destroy one object but not all
#1
Posted 07 May 2012 - 07:04 AM
K....so I have all these blocks (all the same object) and I want them to crumble one by one as I walk across them. So HOW do I destroy one block without destroying ALL the blocks in the room?
I will give credit to you on my game for helping me with this....cause this is the last problem I am facing for this game (i think). Thanks.
#2
Posted 07 May 2012 - 07:06 AM
When it collides with the player use this code:
instance_destroy();Hope that helped.
- Ysmor
#3
Posted 07 May 2012 - 07:16 AM
maybe, put some code in the block object.
When it collides with the player use this code:instance_destroy();Hope that helped.
- Ysmor
That would destroy all the blocks in the room i believe. Cause all the blocks in my room are the same object. Which is my problem. How do I destroy just one of them without ALL of them being destroyed?
#4
Posted 07 May 2012 - 07:19 AM
Create Event:
crumble = 0Collision with player Event:
crumble = 1Step Event:
if crumble = 1 instance_destroy() //or whatever you want
instance_destroy() will destroy that instance only, as it's name suggests...
#5
Posted 07 May 2012 - 07:31 AM
that should do it because every object has its own id number!In the bloc object:
Create Event:crumble = 0Collision with player Event:crumble = 1Step Event:if crumble = 1 instance_destroy() //or whatever you want
instance_destroy() will destroy that instance only, as it's name suggests...
making each object it's own and parents connect them basically!
#6
Posted 07 May 2012 - 07:37 AM
In the bloc object:
Create Event:crumble = 0Collision with player Event:crumble = 1Step Event:if crumble = 1 instance_destroy() //or whatever you want
instance_destroy() will destroy that instance only, as it's name suggests...
Hmm....that didn't work for me. Crap. Thanks anyway. Any other suggestions?
Edit: Wait. Am I supposed to put something in those ()? I tried putting the name of my object but it showed it was an invalid code. So I just left it blank.
Edited by junky1, 07 May 2012 - 07:40 AM.
#7
Posted 07 May 2012 - 07:40 AM
what do you mean?!
In the bloc object:
Create Event:crumble = 0Collision with player Event:crumble = 1Step Event:if crumble = 1 instance_destroy() //or whatever you want
instance_destroy() will destroy that instance only, as it's name suggests...
Hmm....that didn't work for me. Crap. Thanks anyway. Any other suggestions?
it should have worked!
#8
Posted 07 May 2012 - 07:41 AM
with self {instance_destroy()}It never worked for me without the "with self" part, as it would give errors, so IDK.
#9
Posted 07 May 2012 - 07:42 AM
what do you mean?!
In the bloc object:
Create Event:crumble = 0Collision with player Event:crumble = 1Step Event:if crumble = 1 instance_destroy() //or whatever you want
instance_destroy() will destroy that instance only, as it's name suggests...
Hmm....that didn't work for me. Crap. Thanks anyway. Any other suggestions?
it should have worked!
Do I put something in the ()? Cause I just left it blank. I tried to put the name of my obj in there but it showed it was an invalid code. ??
#10
Posted 07 May 2012 - 07:47 AM
you don't put nothing but the parentheses in front of instance destroy!
what do you mean?!
In the bloc object:
Create Event:crumble = 0Collision with player Event:crumble = 1Step Event:if crumble = 1 instance_destroy() //or whatever you want
instance_destroy() will destroy that instance only, as it's name suggests...
Hmm....that didn't work for me. Crap. Thanks anyway. Any other suggestions?
it should have worked!
Do I put something in the ()? Cause I just left it blank. I tried to put the name of my obj in there but it showed it was an invalid code. ??
also put it like this to cause less probs:
if crumble = 1 with self {instance_destroy()}
#11
Posted 07 May 2012 - 07:47 AM
Don't put anything inside the ().
what do you mean?!
In the bloc object:
Create Event:crumble = 0Collision with player Event:crumble = 1Step Event:if crumble = 1 instance_destroy() //or whatever you want
instance_destroy() will destroy that instance only, as it's name suggests...
Hmm....that didn't work for me. Crap. Thanks anyway. Any other suggestions?
it should have worked!
Do I put something in the ()? Cause I just left it blank. I tried to put the name of my obj in there but it showed it was an invalid code. ??
#12
Posted 07 May 2012 - 07:57 AM
#13
Posted 07 May 2012 - 08:04 AM
I'm giving you guys credit in my game. Big help. Thanks!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











