spawn actor and destroy actor
vegasmike1
Member Posts: 192
so here is what i want to do and am having a bit of a problem, so help if you can,please.
I have a game, it has 1 actor replicated 5 times, when a ball hits what I am calling the killer, it removes one of the replicated actors, this happens as i said when the ball hits the killer, I want to spawn a new actor when its destroyed, and reduce the replicated actor, by one. But I can not figure out a good way to kill the actor, reduce the lives of the replicated actor and respawn the actor that was destroyed. If you have any ideas or code that does this, let me know so I can figure it out. Thanks for the help.
I have a game, it has 1 actor replicated 5 times, when a ball hits what I am calling the killer, it removes one of the replicated actors, this happens as i said when the ball hits the killer, I want to spawn a new actor when its destroyed, and reduce the replicated actor, by one. But I can not figure out a good way to kill the actor, reduce the lives of the replicated actor and respawn the actor that was destroyed. If you have any ideas or code that does this, let me know so I can figure it out. Thanks for the help.
Comments
If an actor gets hit (i.e. you use a "rule" to detection "collision/overlap"), place your "destroy" behavior inside a "timer" behavior that is set to "after 0.1 secs". This delays the "destroy" long enough to allow you to change an attribute. You may need to bump up the "0.1" to like "0.15" or even "0.2" if you also make it respawn a copy of itself before dying.
You could also add an invisible "scene controller" actor to monitor the actor count and spawn a new actor when it decreases by one.
Finally, why "destroy" and "respawn" when you can re-use the actor that was hit by either moving it temporarily off-screen or just 'warping' him to a new (or random) location like it was respawned over there (only you didn't have to respawn and waste CPU cycles thus impeding performance).
I got the problem solved by adding a transparent actor that watches the variable for life, so the icons that show life are now getting removed and all is good on that front. Now the problem is however when I spawn the ball, the camera wont track to it and I am sure that I am not the only person who has this issue, and there must be a solution that I am missing.
Mike
As to your camera tracking, is the ball the player? Is the scene larger than the screen? Does your ball actor have the "Camera Follows" (or whatever it is called...not on a Mac at the moment) behavior in it? It isn't nested in something that would prevent it from being interpreted, is it?
Yep I got the actor BALL on screen. That is cool, and I have the replicate thing working perfectly and the lives go away as the ball gets killed when it hits the KILLER object. When the number of LIVES is deremented I spawn the ball again at is original place x and y. All that works. The screen is portrait 320 by 960 and the first ball, that is NOT spawned the camera control is on it and the camera works fine. Its when that first ball gets nailed that the camera goes dead so to speak. I thought that the spawned actor, would still have the name ball, and the control of the ball would be the same. the funny part is this, ok not so funny but the other attributes of the original ball, are good, in other words it collides as its supposed to, it does all its stuff from the main ball actor, it moves by acceleration the spawn ball acts like the first ball. Its just that the camera says, I guess, ok that ball is dead and I am too. Or something. Probably I have something else messed up just dont know where to look. it seem to have worked before so it has to be some dumb thing I am doing or not doing.
In my current/new project, I have "Control Camera" pinging back and forth across a few different actors depending on what is happening. I think the "Control Camera" behavior is pretty solid.
Maybe the camera "box" is too wide/tall? Maybe narrow/shorten it down a bit?
Mike