I’ ve got a dungeon split in a bunch of rooms. When you enter a room, you “activate” it : it sends a message, other rooms are covered with a roof, this one shows, and some events (depending on the room) occur.
Well, the most frequent event would be some monsters appearing. But I want them to disappear when leaving the room, to prevent them to stick to the wall trying to follow the character, and because I think letting all foes in the dungeon run their AI at the same time wouldn’t be good (there could be many).
The first part is easy, I’ve got “spawner” empties, with an associated room number property, and when the current room changes to theirs, they add an enemy object.
Problem is I don’t know how to deactivate the enemies. I’ve found there is a getLastCreatedObject() method for the add object actuator, but it seems I can’t use this to end the object, or access one of its property.
Does someone know of a way to do this?
For now, you can keep going in and out that center room for massive blob battle :evilgrin:
There is an end object actuator. This ends the life of the object and removes it frome the scene. If you connect this actuator to the object that has to be added you can remove all those objects in the room. Hope this helps…
I know that, but the problem is I don’t know how to trigger this on the right objects.
On static room-dependant objects (e.g roofs and spawners) I added a property to mark which room they are part of. But I can’t do this with created objects.
This would not be a problem if I could trigger the end actuator by script, from the spawner (since it has the room number property).
have you tried sending a message to the added in object… then you check to see if the property has changed then end the object?
Do you mean, sending a message with the current room just after creation, and save it in all the new objects?
That should work… :eek: This is so simple I’m ashamed I didn’t think of it, this doesn’t even need scripting!
–>well added in objects can contain properties etc… so you should be able to send messages… but there is a bug with added in objects… I don’t know if it affects the ability to do this to send messaged… with the current bug it might only detect the last added in object instead of keeping track of each instance of the object that has been added to the scene… basically it’s kinda of impossible to make anything usefull with the add in object bug…
Really? Well, for now, this seems to work for me… But with the message it’s true that I don’t need to keep track of each object, only to send a global message for all. I’ve got 2 enemies spawned at the same time, and they disappear when I leave the room, as expected.
glad to know you got it working
Mostly, yes. It works great for the “stupid critter” style of enemies : they just bounce in your general direction, and they only use physics, not even need to script. Just a matter of collisions tests.
Now I’m trying to add more complicated enemies, with armature-based animation, and that can throw stuff at you. I don’t plan to make them particularly clever, but it seems quite harder nonetheless, since each copy would have to control the right armature… Is this even possible? If not, I guess I’ll go back to a static system…
I’ve not tried it before, but I would recommend that you put the armature and the model in the hidden layer for adding, then parent the model to the armature as you normally would for in-game use. Now when you add the monster, just add the armature, not the model. The armature should bring a copy of the model with it, and everything should function properly.
Thanks, I’ll try that. But in fact, for now I even have a parent for the armature itself, a simple box that I use for collision check, and move control, etc… And I link the box’s controllers to the armature’s actuators to trigger the animations when needed.
Saw this in SnailRose’s tutorial, it’s OK for the player character.
But I’m not sure this will work with several copies of the box.
Maybe I should just throw that box and make the armature the real parent object? But then, can the armature itself be used for collisions (with the floor to begin with)?