playMaker

Author Topic: Spawn from another FSM Graph at a random position.  (Read 2194 times)

AizenSousuke

  • Playmaker Newbie
  • *
  • Posts: 10
Spawn from another FSM Graph at a random position.
« on: September 12, 2014, 05:17:29 AM »
Hi

I'm trying to spawn a prefab gameobject from a controller gameobject in the scene using an FSM action (Create Object). I've already randomed the values using random float to random the x and y cood of the point where I want to spawn the prefab. However, when I run the FSM the values are there but the spawned prefabs are still at 0,0,0.

What could be the problem here?

I'm very sure I'm storing the values correctly. I wonder why Playmaker couldn't set the transform of my prefab after it instantiate it.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Spawn from another FSM Graph at a random position.
« Reply #1 on: September 12, 2014, 10:14:13 AM »
I can't spot anything wrong from the screenshot.

If you pause your game before the Create Object action, is your spawn position variable already set to something other than 0,0,0?

What happens if you manually set the spawn position variable to say 5,5,0 (before runtime) and then create your object - is it in the correct position then? (so without any random setting)

AizenSousuke

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Spawn from another FSM Graph at a random position.
« Reply #2 on: September 12, 2014, 09:10:59 PM »
I can't spot anything wrong from the screenshot.

If you pause your game before the Create Object action, is your spawn position variable already set to something other than 0,0,0?

What happens if you manually set the spawn position variable to say 5,5,0 (before runtime) and then create your object - is it in the correct position then? (so without any random setting)

I did try that. The spawn position is updated with the ones I randomed. I also tried manually but the object still is at 0,0,0. No other scripts are interfering with the spawn position except this fsm graph of playmaker.

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Spawn from another FSM Graph at a random position.
« Reply #3 on: September 12, 2014, 10:13:56 PM »
Oh, it looks like your objects (TapObj) are children of your UI Root object.

I would probably just make them in the top level of your hierarchy, see if that fixed the problem. (they're likely positioned in relation to the UI Root object's settings)

AizenSousuke

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Spawn from another FSM Graph at a random position.
« Reply #4 on: September 13, 2014, 02:05:01 AM »
Oh, it looks like your objects (TapObj) are children of your UI Root object.

I would probably just make them in the top level of your hierarchy, see if that fixed the problem. (they're likely positioned in relation to the UI Root object's settings)

They're spawn as a child because it's an ngui sprite object. if I delete the ngui part from the prefab it still spawns at 0,0,0.

Hmm... when I try running the code from the spawned prefab itself I could get it to set the position properly. How come I can't do it from this object o.O
« Last Edit: September 13, 2014, 02:07:47 AM by AizenSousuke »