playMaker

Author Topic: Deactivate / Activate Game object  (Read 5280 times)

Crableg

  • Playmaker Newbie
  • *
  • Posts: 8
Deactivate / Activate Game object
« on: May 21, 2016, 09:21:44 AM »
So i have a game object (a wall) that moves until it hits a collider, then deactivates, what i am trying to do is once it has been deactivated, to activate it again at its original position.

The Deactivating part is working and the wall disappears on collision, but it wont respawn, i am still very to to Playmaker, and i know its probably a simple solution so if anyone can help me respawn a prefabbed game object back where it started it would help

The FSM image is attached, thanks!

600

  • Moderator
  • Hero Member
  • *****
  • Posts: 728
    • 600
Re: Deactivate / Activate Game object
« Reply #1 on: May 21, 2016, 09:32:24 AM »
Hello,

To activate, you must do it from other game object. If you deactivate the owner the FSM is not working on non-active game object and can not activate it self. Also I believe you don’t need the Every Frame check when activating.

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Deactivate / Activate Game object
« Reply #2 on: May 21, 2016, 10:26:22 PM »
What 600 said, is once an object is deactivated, you cannot reactivate from any FSM on the object.

An easy way to accomplish what you want, is to create an empty game object, then associate your moving wall as a child object of the empty game object.  When you do it this way, the wall can deactivate itself, but the empty game object (parent) is still active.

For the playmaker code on the Empty Game Object, create a boolean called RESTART and set it to false.  Create playmaker Boolean Test action that checks every second for RESTART being true.  When RESTART is true, use the set position action, to set its X/Y/Z position in the scene.  Then reactivate the action.

Then, when the wall collides with something, have it set FSM BOOL (RESTART), on the Empty Game Object.  Then have it deactivate itself.

Or alternative thats even easier... with your current setup.  On the final step, dont deactivate the object at all.  Instead have it restart at its original position by getting the X/Y/Z values of its original position and storing them in a variable.  Then when its time to reset, you just reset its position variables instead of deactivating it.

Crableg

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Deactivate / Activate Game object
« Reply #3 on: May 23, 2016, 06:48:58 AM »
Or alternative thats even easier... with your current setup.  On the final step, dont deactivate the object at all.  Instead have it restart at its original position by getting the X/Y/Z values of its original position and storing them in a variable.  Then when its time to reset, you just reset its position variables instead of deactivating it.

Thanks! This is what I ended up doing and its working great, knew it would be a simple solution! I think its more about learning the Playmaker actions.