playMaker

Author Topic: Using FSM on dynamically created game objects without prefabs  (Read 2624 times)

elija

  • Playmaker Newbie
  • *
  • Posts: 4
Using FSM on dynamically created game objects without prefabs
« on: November 06, 2013, 01:06:49 AM »
Hello,

What would be the proper way of designing and attaching FSMs in a game where game object are automatically created in runtime without prefabs?

Thanks
Elija

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using FSM on dynamically created game objects without prefabs
« Reply #1 on: November 06, 2013, 01:10:08 AM »
Hi,

 What kind of "gameObject" you woul dwant to create?

 you can create objects by referencing ones existing in your scene, so you don't have to use prefabs this way, but you can only spawn objects that exists already in your scene.

Why don't you want to use prefabs? this is the Unity way of dealing with creating objects at runtime.

bye,

 Jean

elija

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Using FSM on dynamically created game objects without prefabs
« Reply #2 on: November 06, 2013, 01:17:30 AM »
I guess I'll have to create a prefab with an empty mesh filter and load the mesh in runtime, then I could use this prefab to host a FSM compoment.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using FSM on dynamically created game objects without prefabs
« Reply #3 on: November 06, 2013, 01:19:56 AM »
Hi,

 yep, perfectly fine. And yourFsm handles the logic of knowing what mesh to load. It will be very powerful actually.

bye,

 Jean

elija

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Using FSM on dynamically created game objects without prefabs
« Reply #4 on: November 06, 2013, 01:29:50 AM »
another question,

does FSM logics run every frame?
is there a way to control the invocation frequency?

Thanks
Chen

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using FSM on dynamically created game objects without prefabs
« Reply #5 on: November 06, 2013, 01:32:34 AM »
Hi,

Some actions performs a task and then idle, so not everything works everyframe.

 most actions have a "EveryFrame" option, that's th emost common way to control freqency.

Are you after something else? like controlling frequency based on game events?

bye,

 Jean

elija

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Using FSM on dynamically created game objects without prefabs
« Reply #6 on: November 06, 2013, 01:37:26 AM »
in a FSM you might like to sample some indication but its not needed at every frame. Is there a way to control how frequent conditions are being invoked?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using FSM on dynamically created game objects without prefabs
« Reply #7 on: November 07, 2013, 01:44:35 AM »
Hi,

To answer properly, I'll need to know exactly what you mean by frequent and where it originate from, is it a raycasting, a trigger, a logical state of your game play? and how often is it? x/sec, x/per minutes, else?

Depending on these infos, a lot if different options are available.

bye,

 Jean