playMaker

Author Topic: State Firing Twice  (Read 2236 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
State Firing Twice
« on: December 12, 2012, 06:23:14 PM »
I have a state that seems to be firing twice.  
It does not loop to itself, and only has one input.  The state itself is an initialization state for creating, finding and enabling/disabling various gameObjects in the scene.  When it finishes it exits from the FINISHED event, which is the only event on the state.

The state has only one Create Action, but it began creating two game objects for some reason.  
I removed all other FSMs in the scene, and it still occurred.  
I isolated the state that was creating the two gameObjects and it still occurred.
I added a second Create gameObject Action to the same state, and it created two of that object as well.
I also disabled some nonrelated "Every Frame" Actions in the same state, in case that were causing a bug somehow, but this did not help.

My project is massive, but this is one of the examples of a random change in my FSMs like I outlined here the other day.  I can't faithfully reproduce this, otherwise I would file a bug report with the steps.  
I will happily send my project to Alex or Jean if either of you can offer assistance.

Thanks for any suggestions.
« Last Edit: December 12, 2012, 07:01:53 PM by artician »

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: State Firing Twice [SOLVED]
« Reply #1 on: December 12, 2012, 06:57:07 PM »
Okay I discovered what was happening, but I'm still not certain why.  Problem solved, here was the cause:

In my initialization state, I create the main camera, and assign a target to it.  I've simplified it a little, but the actions break down like this:

Create Object -> Camera
Get Component -> Camera Script Target Property
Create Object -> Camera Target (has FSM)
Get Component -> Camera Target Transform
Set Property -> Camera Target>>Target Transform
Send Event -> Camera Target>>Update

When the Send Event Action fires to the Camera Target object, a second Camera object is created.
There are no Actions on the Camera Target object relating to the Camera.  
The only Actions on the Camera Target are:

Find GameObject -> GameManager(main FSM holder)
Get Int Variable from GameManager

The int variable is used later for spawning of other unrelated objects around the player.  None of them have any scripts that reference the Camera object, and the anomaly occurs before it's ever used.

What's even more strange is how whatever gameObject I Create in this state, it is created a second time.  It can be a cube, a character, or any other gameObject without an FSM or scripts of any kind.  But when I Send Event to the Camera Target Object, whatever objects were created in that State are created a second time.

If I send Event to the Camera Target object in the state after the initialization state, the objects are still created a second time.

As usual, these FSMs were functioning previously without this anomaly.  Maddening.


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3998
  • Official Playmaker Support
    • LinkedIn
Re: State Firing Twice
« Reply #2 on: December 12, 2012, 08:26:41 PM »
If you open the FSM Log do you see the FSM start twice? Could it be possible that the GameObject is getting disabled then enabled? That would reset the FSM and re-fire the start state...

I'd love to see a small repro scene for this problem. Can you send me one?

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: State Firing Twice
« Reply #3 on: December 13, 2012, 12:18:16 PM »
Trying to get a compact example for you.  Will PM you!