best way to spawn an enemy

Started by
8 comments, last by Liquidus4 21 years, 4 months ago
i need enemies to respawn elsewhere in the level after they die. They need to go to a certain location and wait there until it is time for them to attack. What is the best way to do this?
The funny thing about driving a car over a cliff is, you still hit those breaks. Hey! Better try the emergency break!
Advertisement
Zombies !
-Da Mr.RaSt3RiZah-
That kind of question is really implementation-specific. Hopefully you''ve incorporated enough into your design to be able to handle these kind of situations.

You''ll probably need some sort of state machine to handle the waiting part. The respawn part is nothing more than changing the state (dead->alive or whatever) and moving to a new location.
Member of the Unban nes8bit or the White Rhino in my Basement Gets Sold to the Highest Bidder Association (UNWRBGSHBA - Not accepting new members.)Member of the I'm Glad Mithrandir Finally Found an Association that Accepts People with his Past History Association (IGMFFAAPPHA)
Respawning enemies is pretty cool! However, the best way to do it involves changing the enemies "Level Coordinated" (level''s point of reference) so that the enemy appears in a different part of the level. The enemy object should have a "die" flag that can be turned on and off. After changing the enemy''s coordinates (level coordinates) you would turn the "die" flag off. That''s the best way that I see how to do it. Good luck!


Hey, don''t forget to visit my page... by clicking here!
the state machine is pretty much the way i am doing it now. The game is a 3d version of smash tv, so when the enemies die they go to their assigend door until the door is full of enemies, then the door opens, the enemies ai constantly checks for an open door, and when it finds it open, it goes out. This just doesn''t seem like the most efficient way, and the coding gets confusing.
The funny thing about driving a car over a cliff is, you still hit those breaks. Hey! Better try the emergency break!
The door should notify everyone in the room that it opened. So really all the creatures should be doing is checking if their event queues are empty or not which they should be until the door opens. If you are really worried about it you can gen them in the inactive list and have the door move them into the active list when it opens. The door could gen them for that matter as it opens.
Keys to success: Ability, ambition and opportunity.
I was wanting to make the door tell everyone that is is open, the probelem is that the door class is defined before the enemy class, so the door class cannot access anything in the enemies class. If i defined the enemies class first, i couldn''t access the x, y position of the door from the enemies funtcion, because a door class wouldn''t exits. I guess what i need to now is how to get to classes to communicate to each other regardless of the order they are defined.
The funny thing about driving a car over a cliff is, you still hit those breaks. Hey! Better try the emergency break!
err...

class door;
class enemy;

EDIT: before definitions

[edited by - Imperil on November 21, 2002 12:22:19 PM]
couldn''t the door class have something like this?

class Door{ ... //your other stuff bool Open_Close; ... //other stuff still}class Enemy{ void checkIfAbleToMove (/*hypothetical of course*/ bool Door.Open_Close); ...//other stuff}could that work?    

Beginner in Game Development?  Read here. And read here.

 

Thanks everyone, i''ve got it working now. I put a pointer to a door object in the enemy. In the enemies initialization takes a door object as an argument which is assigned to the enemies door. When an enemy dies, it moves to its door''s xy position, dissapears, and adds 1 to it''s doors enemy number. The door class has code do check when it is full, and changes bool isOPen to true. It then checks to see when its door is open using it''s isOpen, when this is true, it comes back to life.
The funny thing about driving a car over a cliff is, you still hit those breaks. Hey! Better try the emergency break!

This topic is closed to new replies.

Advertisement