playMaker

Author Topic: 'Destroy Self' prevents object to be reactivated on spawn..  (Read 2761 times)

Neikke

  • Full Member
  • ***
  • Posts: 134
'Destroy Self' prevents object to be reactivated on spawn..
« on: October 21, 2017, 05:08:43 AM »
Hi, 

Here's what I got. I have a single platform with a few coins as prefab which is being pooled infinitely. On coins I have a simple FSM chain which is basically just Add 1 to CoinScore and do 'Destroy Self'. The problem is that after destroying a coin, it won't be reactivated in the next pooled platform.. How do I avoid this situation? Thanks in advance!

Attaching screens of FSM on coins
« Last Edit: October 21, 2017, 05:10:49 AM by Neikke »

Deek

  • Full Member
  • ***
  • Posts: 133
Re: 'Destroy Self' prevents object to be reactivated on spawn..
« Reply #1 on: October 21, 2017, 07:02:18 AM »
By disabling it instead of destroying it (with the action "Activate Game Object"). By destroying you completely remove it from the currently active scene.

On the FSM component in the Inspector you should set it to reset on enable (which should be ticked by default).

Neikke

  • Full Member
  • ***
  • Posts: 134
Re: 'Destroy Self' prevents object to be reactivated on spawn..
« Reply #2 on: October 21, 2017, 07:26:22 AM »
Thanks for the reply! But I do have 'Reset on Disable' on FSM component checked as on - no effect.

I tried DeActivating via Activate Game Object but it just looks like it just goes into deactivated mode and then stays in it forever for every other spawning prefab..

Deek

  • Full Member
  • ***
  • Posts: 133
Re: 'Destroy Self' prevents object to be reactivated on spawn..
« Reply #3 on: October 21, 2017, 07:48:00 AM »
What kind of pooling do you use? (if you use an Asset, which one, if you made your own system, maybe show its process)

Also as an alternative to pooling you could create the coins when needed and destroy them after a set amount of time (e.g. a minute).

Neikke

  • Full Member
  • ***
  • Posts: 134
Re: 'Destroy Self' prevents object to be reactivated on spawn..
« Reply #4 on: October 21, 2017, 08:00:17 AM »
What kind of pooling do you use? (if you use an Asset, which one, if you made your own system, maybe show its process)

Asset? Sorry what do you mean? I use MoreMountain's object pooler script which takes assigned prefabs from project, clones and moves them in a preset speed towards player.

Deek

  • Full Member
  • ***
  • Posts: 133
Re: 'Destroy Self' prevents object to be reactivated on spawn..
« Reply #5 on: October 21, 2017, 12:01:44 PM »
You haven't enabled "Can Pool Same Object Twice" in your Multiple Object Pooler script, that might be the cause of the problem.

An Asset is anything you can get from the Unity AssetStore (just like PlayMaker), so unitypackages that contain sounds, sprites, or whatever the asset creator contributes (you for example seem to use the Corgi Engine Asset).
I asked because it narrows down the sources of possible problems related to yours (if it would have been an own implementation, the problem was likely to be somewhere in there).

Neikke

  • Full Member
  • ***
  • Posts: 134
Re: 'Destroy Self' prevents object to be reactivated on spawn..
« Reply #6 on: October 21, 2017, 12:46:56 PM »
You haven't enabled "Can Pool Same Object Twice" in your Multiple Object Pooler script, that might be the cause of the problem.

An Asset is anything you can get from the Unity AssetStore (just like PlayMaker), so unitypackages that contain sounds, sprites, or whatever the asset creator contributes (you for example seem to use the Corgi Engine Asset).
I asked because it narrows down the sources of possible problems related to yours (if it would have been an own implementation, the problem was likely to be somewhere in there).

Ah yes I'm using Corgi. Really stuck here..

I'm trying to go the other way and now instancing a coin at Placeholder position defined by empty GameObject. Let's see where it gets me