playMaker

Author Topic: Duplicate Gameobject + set each's parent to specifics gobj  (Read 4178 times)

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Duplicate Gameobject + set each's parent to specifics gobj
« on: November 13, 2014, 10:58:45 PM »
Hey!

( the game is a RPG type, this concerns a spell/damage logic )
I have a prefab (spell) that i load using playmaker, i then attribute it some values based on the caster, a target, and then send it to that target and make it process.

This works like a charm as if i have one target, knowing i would like to send that gameobject (spell) to multiple target ( enemies or allies ), what would be the best option ?

My first idea is to duplicate the gameobject once the values are set, then send each instance to each target; i was thinking about using a Tag for allies and enemies, a sort of count to know how many allies/enemies alive, duplicate the gameobject that amount of time, and send one instance per Tagged target.

It would be great to have your opinion on what to use to achieve that goal, if there are some specific actions that could help me:)

Thanks in advance,
Nico

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #1 on: November 17, 2014, 06:03:28 AM »
Up,

Any ideas?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #2 on: November 17, 2014, 07:05:34 AM »
It sounds like you were on the right track, is it not working out?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #3 on: November 18, 2014, 04:13:34 AM »
I have an idea on the procedure but not how to realise it, that's the problem :)

The main issue is how to duplicate a gameobject while keeping the actual FSM's state.

So when the duplicated gameobject is sent to the target, it's supposed to already have some variables set from the first steps of the FSM and it's too late to get these values once the gameobject it's sent to the target ( in the same FSM i get some values from the caster, get the target type, send it to the target, get some values from the target, process the damage )

There's probably some workaround but it want to do in a clean way :)

I found out the Tag Count that can be used to know the number of instance of this game object that should be created, that's fine for this part. The part where i don't know yet how to solve it is to send each instance to one of the Tagged gameobject and not end up with all on the same gameobject.

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #4 on: November 20, 2014, 06:33:15 AM »
Any idea on how to duplicate a gameobject with a state machine and keep that actual state machine's state?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #5 on: November 20, 2014, 07:26:40 AM »
As far as I know you need to copy all the relevant information over manually when you create the fsm. I haven't tested using Create Object on an existing scene object that is not in its default state before, you may get some results from that.

I believe there is a Set State action on the forum or on Eco, that should help navigate the fsm on the new object.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #6 on: November 20, 2014, 11:13:42 AM »
Create object reset the FSM to it's initial state and all it's variables values, it doesn't keep them :/

I think the only solution will be to split my FSMs in the same gameobject, forward all the values to the newly created objects, and send an event to start all of these FSM's once the values are in... snif.. which there would be a simpler way   :'(

Any idea on how to send only one of these game object to each of the target? Let's say i have 5 enemies, the spell is ready on my caster ( as a game object ), i duplicates 4 times that spell game object, and then i need to send one instance to each of the enemies that has the right tag.

nighty9

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #7 on: November 24, 2014, 07:17:08 AM »
Anyone got an idea how to duplicate a gameobject while keeping it's actual fsm's status?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Duplicate Gameobject + set each's parent to specifics gobj
« Reply #8 on: December 08, 2014, 03:02:56 AM »
Hi,

 That's going to be tricky. You'll need to serialize your data yourself unfortunatly. Typically, you can save your source fsm data into a ArrayMaker Hashtable, then re apply on your duplicated gameobject these values from the hashtable back to the fsm variables.

 I think this is a valid request for a new actions for ArrayMaker, the ability to save all fsm variables in a hashtable and it's counter action to load from a hashtable. I would also make an option to only load/save variables set to "show in inspector" or not.

Please bump this regularly ( every monday :) until it's done! I need it...

 Bye,

 Jean