How can I spawn an actor before changing a scene?

dennisboysdennisboys Member Posts: 1
edited March 2013 in Working with GS (Mac)
I am run into a situation and could not figure out a way to solve.

I am making a shooting game. I want to realize that when the player's health is 0, it spawn an explosion actor, then the game changes to a Lose scene. However, the game change to Lose scene immediately when the player's health is 0 and the explosion actor is not quick enough to display.

How can I solve this? I just want the explosion actor displays before going to the lose scene.

Currently, my game logic is:

When player's health is 0:
1. then display explosion actor;
2. destroy the player actor;
3. change to the lose scene;

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @dennisboys You've almost answered your own question.... "the explosion actor is not quick enough to display."

    So you have to tell GSC to wait until the explosion actor has finished before the scene is changed. And to do this, you use the Time Behaviour.

    So try this :

    When player's health is 0:
    1. then display explosion actor;
    2. a Timer set to After how many secs you want the image to appear
    3. destroy the player actor in Timer above;
    3. change to the lose scene (also in Timer above);

    Hope that helps.

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

  • dennisboysdennisboys Member Posts: 1
    Thanks gyroscope,

    I followed your instructions, but did not work the magic.

    Now the logic is:

    when player's health is 0:
    1. Spawn the explosion actor;
    2. Destroy the player actor;
    3. Set Timer, after 2 seconds -> go to Lose scene;

    However, the game never goes to Lose scene. Any idea why?
  • CORE GameCORE Game Member, PRO Posts: 280
    You are destroying the actor which is having the timer, so basically before it starts counting the actor is being disposed.

    Add the timer to the explosion actor (if you are using this specific explosion only for the player death) and don't destroy it after.

  • lycettebroslycettebros Member, PRO Posts: 1,598
    Yep seems like @fsoufi is right - if the delay script is on the actor you are destroying it will not work. You can always get the actor to change an attribute which then sets of the timer on an external controller (actor) to change the scene.
Sign In or Register to comment.