playMaker

Author Topic: Pmt Despawn in custom poolmanager 2 actions [SOLVED]  (Read 6555 times)

alternativee30

  • Playmaker Newbie
  • *
  • Posts: 24
Pmt Despawn in custom poolmanager 2 actions [SOLVED]
« on: June 07, 2012, 12:11:38 AM »
My problem is as follows
I am setting up a state machine to spawn / despawn two different characters on alternating intervals for a custom character generator. Right now the state machine i am trying to implement will switch between male and female prefabs.

After i use the Pmt Despawn action and drag my prefrab to the applicable state i am told that my prefab does not belong to my Spawnpool. I am guessing this is because the prefab i dragged to the action does not have the -(clone)001 tag on it. however i cannot figure out how to preload this prefab (with the clone tag) except at runtime but those settings do not get saved to after play is stopped.

Using the exact same method for the pmt spawn action i have no problems while spawning.
I was able to glitch it out and despawn my character using the pmt spawn action but that accidental functionality went away sometime yesterday.

I am very new to "scripting" and playmaker has been a lifesaver for me who knows little to nothing about code.  
all help is much appreciated.
« Last Edit: June 08, 2012, 09:08:33 PM by alternativee30 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #1 on: June 07, 2012, 01:19:02 AM »
Hi,

 It looks like you haven't set up the pools properly based on your requirements. Could you send ma a private message, I think I would need to have access to the project to try and solve this.

 Bye.

Jean

alternativee30

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #2 on: June 07, 2012, 07:13:54 AM »
After reading around the forum this seems to be one of my problems. i am not exactly understanding yet how to plug an object via script at runtime but i will continue searching.

http://hutonggames.com/playmakerforum/index.php?topic=1647.0

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #3 on: June 07, 2012, 09:35:34 AM »
Hi,

 you can access a prefab from a pool via its name if I recall, which means you can overcome this problem of referencing other objects of the scene within the prefab. Note tat this restriction only apply DURING editing, at runtime, you can maintain references of objects in a prefab, so you can create a routine when a prefab starts to find another prefab or something like that, or store that reference in a global var and access it in your prefabs.

 Bye,

 Jean

alternativee30

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #4 on: June 07, 2012, 06:38:28 PM »
Quote
Hi,

 What I do to overcome this limitation is to plug things are run time like Alex mentionned, this works very well, but you need to be very organized ( cause you would reference the Fsm by typing its name instead of selecting it from a list, since you won't get all the playmaker actions ui helpers during author time ( since you can't reference it, playmaker can't give you any drop down list of Fsm).

 Bye,

 Jean

I am having a hard time figuring out how to accomplish this. how would i go about typing it in by name instead of selecting it from a list? I have tried the following javascript as well with no success.

Code: [Select]

function HumanMaleDespawn () {

PoolManager.Pools["CharacterSpawner"].Despawn("humanmale(Clone)001");


It results in the following error

Assets/scripts/CharGen/HumanMaleDespawn.js(4,46): BCE0023: No appropriate version of 'SpawnPool.Despawn' for the argument list '(String)' was found.
« Last Edit: June 07, 2012, 06:40:20 PM by alternativee30 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #5 on: June 08, 2012, 06:54:55 AM »
Hi,

 you can get a gameObject reference by its name using the"find gameObject" action

https://hutonggames.fogbugz.com/default.asp?W51

 one other way is to reference that gameObject in a global Fsm variable , and you can access global variables from prefabs.


 bye,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #6 on: June 08, 2012, 04:05:50 PM »
Hi,

 you go in the "variable" tab, and create a new variable of the type you want ( here  of type gameObject), then back to the state tab, select your action, and the store field and it will be listed ( if variable type if matching).

 bye,

 Jean

alternativee30

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #7 on: June 08, 2012, 05:26:43 PM »
sorry that was a waste of a question. didnt mean to ask it.


So i have set up my prefab as a global variable (HumanMaleDespawn) now within playmaker and am attempting to reference this script via "send message" state

Code: [Select]
function HumanMaleDespawn()

{

PoolManager.Pools["CharacterSpawner"].Despawn(HumanMaleDespawn.Variable);

}

I am returned the following lengthy error.

NullReferenceException: Object reference not set to an instance of an object
SpawnPool.Despawn (UnityEngine.Transform xform) (at Assets/Plugins/PathologicalGames/PoolManager/SpawnPool.cs:636)
HumanMaleDespawn.HumanMaleDespawn () (at Assets/scripts/CharGen/HumanMaleDespawn.js:4)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
HutongGames.PlayMaker.Actions.SendMessage:DoSendMessage() (at Assets/PlayMaker/Actions/SendMessage.cs:104)
HutongGames.PlayMaker.Actions.SendMessage:OnEnter() (at Assets/PlayMaker/Actions/SendMessage.cs:35)
HutongGames.PlayMaker.FsmState:OnEnter()
HutongGames.PlayMaker.Fsm:EnterState(FsmState)
HutongGames.PlayMaker.Fsm:SwitchState(FsmState)
HutongGames.PlayMaker.Fsm:DoTransition(FsmTransition, Boolean)
HutongGames.PlayMaker.Fsm:ChangeState(FsmEvent)
HutongGames.PlayMaker.Fsm:Event(FsmEventTarget, FsmEvent)
HutongGames.PlayMaker.Fsm:Event(FsmEvent)
PlayMakerMouseEvents:OnMouseDown()
UnityEngine.SendMouseEvents:DoSendMouseEvents()



alternativee30

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #8 on: June 08, 2012, 06:12:56 PM »
To give you a better idea of what my state machine is supposed to do.
Dont ask me why i made this 4 states instead of 2. Im not really sure. Intended function-> while humanmale is spawned. humanfemale is despawned and vice versa.



Plus the javascript to access the global variable to despawn the man/woman

Code: [Select]
function HumanMaleDespawn()

{

PoolManager.Pools["CharacterSpawner"].Despawn(HumanMaleDespawn.Variable);

}

alternativee30

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Pmt Despawn in custom poolmanager 2 actions
« Reply #9 on: June 08, 2012, 09:08:13 PM »
Figured it out, I had to set up a global variable and send event in my state tables to activate that global event to despawn the transform javascript attached to my player prefab. heres what it looks like. I hope this helps other newbies like me to create a despawn button. Thank you for your help as well. Please let me know if there is a more efficient way to do what i just figured out as well.

« Last Edit: June 08, 2012, 09:10:33 PM by alternativee30 »