Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre 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.
// (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
-
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
-
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.
-
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
-
great, just found this thread as im about to buy poolmanager2, as always jean thank you very much
-
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
-
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
-
Thank you jean soon as I get home from work ill test that out
-
ahh i have to store it in a game object variable,works perfect thank you
-
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
-
is there a simple way to despawn the gameobject pooled where we have the FSM
like Game object:user Owner
-
Hi,
sorry, I don't get the question, can you rephrase? thanks :)
bye,
Jean
-
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??
-
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.