playMaker

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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14237
  • Official Playmaker Support
    • View Profile
Pool Manager 2 deSpawn
« on: January 12, 2012, 01: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 17, 2012, 11:49:21 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14237
  • Official Playmaker Support
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #1 on: January 17, 2012, 11:51:09 PM »
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
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #2 on: October 05, 2012, 03: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: 14237
  • Official Playmaker Support
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #3 on: October 07, 2012, 10:49:42 PM »
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
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #4 on: October 19, 2012, 11:35:25 AM »
great, just found this thread as im about to buy poolmanager2, as always jean thank you very much

gamedivision

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #5 on: December 17, 2012, 04: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: 14237
  • Official Playmaker Support
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #6 on: December 18, 2012, 01: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
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #7 on: December 18, 2012, 03:47:42 AM »
Thank you jean soon as I get home from work ill test that out

gamedivision

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

gamedivision

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #9 on: December 18, 2012, 01: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
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #10 on: March 03, 2013, 03: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: 14237
  • Official Playmaker Support
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #11 on: March 15, 2013, 07:08:24 AM »
Hi,

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

bye,

 Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 227
    • View Profile
Re: Pool Manager 2 deSpawn
« Reply #12 on: February 01, 2015, 11:44:54 AM »
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: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Pool Manager 2 deSpawn
« Reply #13 on: February 01, 2015, 12: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.