playMaker

Author Topic: Pool Manager 2 deSpawn  (Read 9600 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Pool Manager 2 deSpawn
« on: January 12, 2012, 03:21:33 AM »
Hi,

 Following this thread:

 Please find a Pool Manager 2 despawn custom action.

[EDIT] tested, it had few glitches.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;


namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Pool Manager 2")]
[Tooltip("If the passed transform is managed by the SpawnPool, it will be deactivated and made available to be spawned again.")]
public class PoolManagerDeSpawn : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.FsmString)]
[Tooltip("Pool name")]
public FsmString poolName;

[RequiredField]
[UIHint(UIHint.FsmGameObject)]
[Tooltip("GameObject or prefab to deSpawn")]
public FsmGameObject gameObject;

[UIHint(UIHint.FsmFloat)]
[Tooltip("delay")]
public FsmFloat delay;


public override void Reset()
{
poolName = null;
gameObject = null;
delay = 0;
}

public override void OnEnter()
{
DoDeSpawn();
}

void DoDeSpawn()
{
if (poolName.Value == "")
{
return;
}

if (gameObject.Value == null)
{
return;
}

if (delay.Value >0){
PoolManager.Pools[poolName.Value].Despawn(gameObject.Value.transform, delay.Value);
}else{
PoolManager.Pools[poolName.Value].Despawn(gameObject.Value.transform);
}

}
}
}




 Bye,

 Jean
« Last Edit: January 18, 2012, 01:49:21 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pool Manager 2 deSpawn
« Reply #1 on: January 18, 2012, 01:51:09 AM »
Hi,

 Edited the script to fix it. Now it's tested and working well.

 I plan on porting the whole pool manager 2 api in the coming days.
 
WARNING: does not work with playmaker beta. Pool Manager 2 and playmaker have some conflict it seems. It does work with Unity beta tho.

 Meanwhile if you have request on actions related to pool manage 2, let me know, and I'll prioritize the work load.

 Bye,

 Jean

Gorgor

  • Playmaker Newbie
  • *
  • Posts: 1
Re: Pool Manager 2 deSpawn
« Reply #2 on: October 05, 2012, 06:42:14 PM »
I've just download PoolManager2 custom action for PM. The Despawn action is little bit updated - now including failureEvent. But don't you think that the action should call 'Finish()' if the Despawn is successful? So it plays nice and let FSM know that it finished its work? Same goes with Spawn custom action. If not, please educate me for I am just a beginner in writing PM custom actions.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pool Manager 2 deSpawn
« Reply #3 on: October 08, 2012, 01:49:42 AM »
Hi,

 You are actually right, this is a miss, they should call Finish() in any cases, I have updated the package on the wiki, tell me if that's all right.

bye,

 Jean

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: Pool Manager 2 deSpawn
« Reply #4 on: October 19, 2012, 02:35:25 PM »
great, just found this thread as im about to buy poolmanager2, as always jean thank you very much

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: Pool Manager 2 deSpawn
« Reply #5 on: December 17, 2012, 06:33:03 PM »
could someone explain how to de-spawn something,i spawn a prefab then add a wait for 1 sec,which then sends an event to a de-spawn but says it cant find anything in the pool,all i want to do is spawn something then de-spawn something

thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pool Manager 2 deSpawn
« Reply #6 on: December 18, 2012, 03:12:57 AM »
Hi,

 Tested and it works ok, check few things to debug this:

-- you need to specify the right Pool Name in the DeSpawn action
-- you need to to specify the right gameObject in the the DeSpawn action

That's pretty obvious, and you could have a problem earlier on, for example, are you sure you are storing the spawned gameObject in a variable when you spawn it? the spawn action let you do that.

 I have attached a modified version of the test scene that comes with the set of actions, it despawn the cube after 4 secs ( check the "pool creator" fsm)


bye,

 Jean

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: Pool Manager 2 deSpawn
« Reply #7 on: December 18, 2012, 05:47:42 AM »
Thank you jean soon as I get home from work ill test that out

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: Pool Manager 2 deSpawn
« Reply #8 on: December 18, 2012, 01:07:36 PM »
ahh i have to store it in a game object variable,works perfect thank you

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: Pool Manager 2 deSpawn
« Reply #9 on: December 18, 2012, 03:24:06 PM »
is there anyway to store particle effects,i have a particle blast that lasts 5 sec,i spawn the particle effect de-spawn it but when i go to re-spawn it,it doesn't play the particle effect.
any ideas

thank you

PIXELCRY

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Pool Manager 2 deSpawn
« Reply #10 on: March 03, 2013, 05:58:18 AM »
is there a simple way to despawn  the gameobject pooled where we have the FSM
like Game object:user Owner

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pool Manager 2 deSpawn
« Reply #11 on: March 15, 2013, 10:08:24 AM »
Hi,

 sorry, I don't get the question, can you rephrase? thanks :)

bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Pool Manager 2 deSpawn
« Reply #12 on: February 01, 2015, 01:44:54 PM »
Unity is freezing/crashing on me if I try to despawn an object that isn't there. Even if I put a FINISH on fail. Am I using an old version of despawn??

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Pool Manager 2 deSpawn
« Reply #13 on: February 01, 2015, 02:11:09 PM »
These are the latest:
https://hutonggames.fogbugz.com/default.asp?W839

Update and see if it fixes it?

I don't think I've tried to despawn an object that isn't there before so I'm not sure how it would behave. I can't really think of a reason it would crash just because of a null reference... Normally I have the object despawn itself.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D