Problem with spawned actor

DesBDesB Member Posts: 39
edited November -1 in Working with GS (Mac)
Hi there
I want to destroy a spawned actor after (say) 5 seconds....how do I do this?
Thanks

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Des: It's a bit of a shortcoming in GS, I think, (and I know a lot of other people would agree) that the Destroy Behavior can only be used by the Spawned actor (or any actor for that matter; they can only destroy themselves). I think I can understand why though; getting actors to destroy other actors mid-way through performing their Rules could cause a lot of "tangles" I'm guessing...

    So, say for example – a bit different from what you require – you wanted a spawned actor to be destroyed when it collides with another actor, you'd have a scene attribute in the second actor which says: Rule when collide or overlap with game.SpawnedActor then set scene.background.Hit to true.

    Then in the actor's prototype that's going to be spawned, put when scene.background.Hit is true then Destroy this actor.

    So back to your original question, the solution is even more straightforward, put a Timer, after 5 seconds then a Destroy Behavior. So every time it's spawned it'll destroy itself after that set time.

    Hope that helps you. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.