Bringing an Actor back to the scene

chongyunxiang

  • Posts: 216
Hi,

I want my actor to leave the scene when I depress the Right button, and reappear after I release the Right button.

I can get my actor to "Kill" itself after I depress the Right button, but it doesn't reappear.

Help?

Thanks!

fillergames

  • Posts: 771
If the actor is already dead, the script will not run.

Try moving the code to the scene, rather than the actor to kill, since the scene's  code runs all the time on the current scene. Unlike an actor, which the code dies along with it.

To set this up, set whatever actor you want to remove on screen with an actor attribute, maybe "Right Hand" or something.

Set the actor for "Right Hand" to the current Right hand actor on screen when the scene is created.

When right is pressed, kill the actor with the attribute "Right hand". And then when right is released, create the actor at the needed position, you'll also have to set the actor attribute to the last created actor in the game script after you create the right hand actor. This is to remove the right hand actor after a new one spawns in.


chongyunxiang

  • Posts: 216
How do I set the actor for Right Hand to the current Right Hand Actor on screen when the scene is created?

I've created an actor attribute on the Scene, but I don't understand your 2nd part. Is it under the Attributes -> Setters?

fillergames

  • Posts: 771
Yes. You set it to choose an actor under the drop box on the setter.

The other one below the spawned actor should be set to last created actor. Here's an example script as an attachment below.

The when created script starts the loops of recycling the actor. As the always updating script will create and destroy actors after the original actor has been killed.

chongyunxiang

  • Posts: 216
I have moved my code to the scene. Now when I press Right, it spawned HandSlap and removed Hand, and when I release, Hand comes back, but HandSlap still remains! HAHA!

I'm trying to study the image you sent. Can I know where did you get the "Set Player Actor to ......" option?

Thanks!

fillergames

  • Posts: 771
It's an Actor attribute, the block itself should be under getters after an attribute was created.

Also, one thing that can be confusing is that Actor and Actor Type are two different attributes with different values.

Actor is a single specific actor on the scene, you can control what this actor does. From a set actor, to last created actor, and an attribute.

Actor Type is a general member actor of the type, which is typically used for creating actors and such. This can be set to any actor type in your game.