playMaker

Author Topic: Add Template FSM to another GameObject at Runtime?  (Read 145 times)

Kathar

  • Playmaker Newbie
  • *
  • Posts: 39
    • View Profile
Add Template FSM to another GameObject at Runtime?
« on: May 12, 2018, 10:26:41 AM »
Probably missing something really obvious here, but I essentially have a GameObject with an FSM, and in this FSM I want it to run through each of the GameObject's children and add an FSM Template to each of them. The children are all loads of different prefabs, so I don't really want to apply the scripts to them all manually in the Editor, would prefer to do this automatically at runtime.

I've seen the Run FSM scripts and such, but it seems like you can only add a new FSM to the current GameObject, so doesn't really work for my needs.

Is there just something I'm missing, or will I need to just modify one of the Run FSM action to achieve this? Thanks a lot!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2952
    • View Profile
    • jinxtergames
Re: Add Template FSM to another GameObject at Runtime?
« Reply #1 on: May 13, 2018, 06:30:53 AM »
Hi,
There is an action on the Ecosystem called 'Run Template F S M'

Maybe that's what you are looking for?

Kathar

  • Playmaker Newbie
  • *
  • Posts: 39
    • View Profile
Re: Add Template FSM to another GameObject at Runtime?
« Reply #2 on: May 13, 2018, 12:22:18 PM »
Thanks Djay, did see that one but doesn't look like I can get it to run the FSM on another object, only the current GameObject, so can't figure out a workaround for that off the top of my head - might just have to bite the bullet and try and make a new action for it :) thanks for your help though!

Marc Saubion

  • Playmaker Newbie
  • *
  • Posts: 48
    • View Profile
Re: Add Template FSM to another GameObject at Runtime?
« Reply #3 on: May 13, 2018, 03:34:35 PM »
Hi.

I think you make a good point so tried to gave it a shot. I failed so far but here are some test I did.

I tried the run FSM but it doesn't work either. When you get out of the state, the FSM isn't running anymore.

I also tried adding and FSM component to the targeted gameobject + set property for the template but I'm not sure how to do that. There are more than one instances of "templates" in the set property and it's a bit confusing. But I guess that's the right direction.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2952
    • View Profile
    • jinxtergames
Re: Add Template FSM to another GameObject at Runtime?
« Reply #4 on: May 13, 2018, 03:44:43 PM »
Hi,
You can actually copy a fsm component and paste to multiple objects.
so you might want to copy a fsm with the template and then select the children and paste.

To select certain children easier (if they have the same name) you can use the search bar.

if the fsms are not to be changed i would not do this @ runtime as it would take longer startup time for your game and more prone for errors.

Kathar

  • Playmaker Newbie
  • *
  • Posts: 39
    • View Profile
Re: Add Template FSM to another GameObject at Runtime?
« Reply #5 on: May 16, 2018, 12:02:12 PM »
Thanks for your help Djay, curiousity killed the cat and all that, maybe I'm just trying to meddle in things I shouldn't! :P

Think you're right, may be best I just add the templates manually Editor - thanks again :)