Game Development Community

Setting up none respawning items

by Tony Oakden · in Torque Game Engine · 02/27/2005 (2:48 pm) · 2 replies

I've created some tokens in my game which are collected by the player walking over them then removed from the world. I call %this.delete() on them after the collision to get rid of them. I don't want them to respawn again until the game restarts so I don't schedule to do this. Everything works fine as far as the collecting of the tokens goes. My problems start when I try to edit my levels. What I want to do is play the levels a bit then make some changes to the level layout and save it again. However what I find is any tokens which have been collected are permanently lost when I save the level. I assume this is becuase the delete() command permanently deletes the tokens from the level. As token placement in my level is critical I don't want to keep accidentally deleting them in this way. I guess I could not use delete and instead put a flag in each token to say if it's collected and write additional code so that if the flag is true the token is hidden and not collided with but this seems like the sort of functionality which would already be in the engine somewhere?

Someone must have done this already?

Any thoughts?

regards,

Tony Oakden

#1
02/27/2005 (3:01 pm)
In item.cs around line 107 you'll find...

if (%obj.isStatic())
      %obj.respawn();
   else
      %obj.delete();


You could change it to...

if (%obj.isStatic())
      %obj.respawn();
   else
      %obj.setHidden(true);


And this would hide the token instead of deleting it.
#2
02/27/2005 (3:50 pm)
Thank you very much! I'll try this when I get in.