I'm having massively inconsistant evaluation in my state machine!
I'm using playmaker to handle a characters actions in an RTS style game.
The first action I've built is the resource gathering one.
The basics of this FSM are as follows.
Startup = get script components and their variables,
Wait State = Wait for the "OnGather" event (triggered from c#).
OnGather starts the loop which is:
1. Get resource variables (ie. is there anything to collect?)
if no return to wait state.
if yes continue.
2. Travel to resource (walk to location of target object)
3. Get resource variables agian (I'm checking/updating variables each collection since multiple characters can collect at the same time)
4. Collect resource
5. Travel to home (when character is full, or resource is empty)
6. Deposite resources at home...
repeat
The problem scenerio:
I spawn a character and tell it to gather from resource A.
The Character gathers until the amount left is 0, so state returns to wait state, and the character is left at home waiting for a new command.
Then if I tell the character to gather from resource B my FSM returns false at state 1. because it thinks resource amount = 0 (where the last resource left at) so it goes back to wait state
At first I thought it was just that the variables weren't updating (and that is part of it). But if I mearly select state 1 in the playmaker editor, (don't change any settings), and reissue the command. It passes state 1.
Oldly it walks to the resource and fails again at state 3 (Same check as state 1 with the same variables).
So my FSM ping pongs my character between home and resource, When at home the resource check shows resourceAmount > 0, then when at the resource the check shows resourceAmount==0, so it returns home, this is the same local variable!!!
Like before if I select the state, this time #3 in playmaker, the variable updates properly and the machine works again... that is until the resourceAmount of the new resource ==0 then I have to repeat the above for the next resource.
All of my code behind is handled by two classes, "Character" and "WorldResource".
All of my variables on these objects when viewed in the unity inspector work/update properly,
I'm using "get component" to save the script component and "get property" to save the variables from my c# code in playmaker.
And "SendMessage" for any method calls to these classes. All methods are of type void and rely on playmaker to refetch the variable values from the classes.
No other state machines are dealing with these variables.
As for variables I'm getting in playmaker they are:
1. character<component> = Owner.Character
2. target<GameObject> = Character.target (character stores what its target is)
3. worldResouce<component> = target.WorldResouce (target object has a WorldResouce component)
4. resourceAmount<int> = worldResouce.resourceAmount (how much resource is there?)
5. sampleSize<int> = worldResource.sampleSize (how much resource is collected per collection)
Although the target gameobject and its WorldResouce variables update properly in playmakers inspector,
the two <int> variables it reads from them don't update untill I select the states in the playmaker editor as mentioned above
I have tried
changing the name of the variables,
changing from int to floats,
changing from get set style properties to simple public fields,
checking/unchecking "Every Frame" options for my evaluations in playmaker...
Breaking prefab instance so FSM is not running on a prefab clone.
Running from another computer
Nothing works.
I recently upgraded from playmaker 1.33 to 1.4, but too much has changed in my setup since I upgraded to determine if that is where my problems stem from.
If you've made it this far thank you for taking the time, & my apology for the long read, just felt I needed to be specific to avoid a lot of back and forth.
Any thoughts?
Win7Pro x64
Unity 3.5.1f2
Playmaker 1.4