Branch Validates As False When It Should Be True

Mon 11. Nov 2019, 15:31

Hello,

Here's the strange problem I'm having:

- I have a template "UseableItems" with feature "ItemBasics" that contain properties "IsOwned" (bool) and "NumberOwned" (int).
- Player inventory is done using the Flow Player. The template "UseableItems" is attached to each flow fragment representing an item, with the following condition on each InputPin: getProp(getObj("aTechName"), "ItemBasics.IsOwned")
- Player inventory works as expected. The branch to the UseableItems flow fragment validates as false when IsOwned is false.
- During the game, player acquires a usable item. Properties "IsOwned" is set to true, and "NumberOwned" set to 1 via custom method "AddRemoveItem()".
- Player inventory works as expected. The branch to the UseableItems flow fragment, with above condition on InputPin, validates as true.
- Player sells item. Properties "IsOwned" is set to false, and "NumberOwned" set to 0 via custom method "AddRemoveItem()".
- Player inventory works as expected. The branch to the UseableItems flow fragment validates as false.
- Player acquires another of the same usable item. Properties "IsOwned" is set to true, and "NumberOwned" set to 1 via custom method "AddRemoveItem()".
- The branch to the UseableItems flow fragment still validates as false. I have checked OnBranchesUpdated using a debugger. For the branch in question, IsValid is false, however, the IsOwned property on the branch.target is true, which is the only condition on the InputPin and on the path to the target. I am also not altering any Articy condition scripts via code at any point throughout my game. (NumberOwned is also correctly set to 1.)

Unfortunately, I'm unable to post the project or code, so I don't expect to receive a conclusive answer to this. Just wondering if you have any idea what might be causing this off the top of your head.

Thanks!
FlowFoSure
 
Posts: 5
Joined: Mon 11. Nov 2019, 14:40

Re: Branch Validates As False When It Should Be True

Tue 12. Nov 2019, 10:20

Hi FlowFoSure,

its a bit difficult to pinpoint the issue in this case, but i try to give you some pointers:

1) Your getProp code with aTechName is that pointing to a different object or to the owner of the pin? If its the same object you should be able to use self instead of the whole getObj() call. Not a problem, just a tip.

2) You mentioned custom methods. If you are using custom methods you have to take special care of branch evaluation that could call those methods. Inside your custom method you have access to a property called IsCalledInForecast. This property will tell you if the method is called when the flow player is just checking the branch without actually traversing along. The flow player will call all methods and change all variables while Forecasting to predict if this branch could be valid. After gathering the branches all variable changes are reverted, but it can't revert custom method calls, so you need to take care of that yourself.

3) I did not fully understood the flow of your application and what is called outside of the flow and what inside. But its important to understand how objects are traversed. For example from one object to another the traversal would look like this: Node A -> OutputPin of A -> Connection -> InputPin of B -> Node B.

4) The property isOwned has nothing to do with that. The branches are built while traversal and at a specific time the scripts are evaluated and the script result is stored in the branch. You can execute the branches for yourself when calling Evaluate on the input pin in question. You can even debug your scripts, as they are turned into C# code for performance reason. It certainly is advanced to do that but maybe worth a try. The scripts are part of the generated source code the plugin creates while importing. Inside this folder you will find an ArticyScriptFragment.cs file. This contains a class with all your script codes inside uniquely named methods. You can search for the objectId and check the methods found for the code in question. You can place a breakpoint here and can debug from here. For debugging purposes you can even change this class, but remember it is automatically overwritten everytime you reimport.

Hope that helps you pinpointing the issue.

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: Branch Validates As False When It Should Be True

Sat 16. Nov 2019, 01:37

Thank you for the help.

I haven't been able to pin point the cause, so I just switched to using global variable sets. Everything is now working correctly.

I have a question in regards to IsCalledInForecast. I am using the if(!IsCalledInForecast) check before all my custom methods, but I've found that for some methods, IsCalledInForecast is never equal to false and the method ultimately doesn't end up executing. Do you have any advice about why this might be the case?

Thanks!
FlowFoSure
 
Posts: 5
Joined: Mon 11. Nov 2019, 14:40

Re: Branch Validates As False When It Should Be True

Mon 18. Nov 2019, 08:52

I have a question in regards to IsCalledInForecast. I am using the if(!IsCalledInForecast) check before all my custom methods, but I've found that for some methods, IsCalledInForecast is never equal to false and the method ultimately doesn't end up executing. Do you have any advice about why this might be the case?


I assume that the method is in a place that is actually called by the flow player (Pins, Conditions & Instruction Nodes). The flow player won't touch scripts in templates.
IsCalledInForecast can only ever be false when its part of a played branch. If that is the case, another explanation could be that its the second argument in an OR statement and the first one already evaluates to true.
Otherwise it could point to a bug, but to prove it i would need ways to reproduce the behaviour.

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 15 guests

Who We Are
Contact Us
Social Links