SharedString Does Not Match

rajdpj

New member
Justin,
I am getting the following annoying error and it causes my project to pause immediately, I have tried many things based upon your documentation and still get the error:
Error: Unable to set SharedVariable - the variable type BehaviorDesigner.Runtime.SharedString does not match the existing type BehaviorDesigner.Runtime.SharedGameObject
UnityEngine.Debug:LogError(Object)
BehaviorDesigner.Runtime.BehaviorSource:SetVariable(String, SharedVariable)
BinaryDeserialization:BytesToSharedVariable(FieldSerializationData, Dictionary`2, Byte[], Int32, IVariableSource, Boolean, Int32)
BinaryDeserialization:LoadField(FieldSerializationData, Dictionary`2, Type, String, Int32, IVariableSource, Object, FieldInfo)
BinaryDeserialization:LoadFields(FieldSerializationData, Dictionary`2, Object, Int32, IVariableSource)
BinaryDeserialization:LoadTask(TaskSerializationData, FieldSerializationData, List`1&, BehaviorSource&)
BinaryDeserialization:Load(TaskSerializationData, BehaviorSource)
BehaviorDesigner.Runtime.BehaviorSource:CheckForSerialization(Boolean, BehaviorSource)
BehaviorDesigner.Runtime.Behavior:CheckForSerialization()
BehaviorDesigner.Runtime.Behavior:GetVariable(String)

I have enclosed a snippet of the code that is causing the issue:
var fleeSourceGameObjectBT = (SharedGameObject)behaviorTreeVariables.behaviorTree.GetVariable ("fleeSourceGameObject");
fleeSourceGameObjectBT = behaviorTreeVariables.fleeSourceGameObject;
behaviorTreeVariables.behaviorTree.SetVariable ("fleeSourceGameObject", fleeSourceGameObjectBT);

public class BehaviorTreeVariables{

public BehaviorTree behaviorTree;
public SharedGameObject fleeSourceGameObject;

I have no clue and this is definitely hindering my current project. I cannot find anything in your documentation that helps this issue or even on youtube or google. The value is being assigned in the external behavior tree so the message makes no sense to me.

1583621529605.png


please point me in the direction of how to fix/troubleshoot this issue or documentation that will clearly explain how to pass and get shared variables/gameobjects(non-global) from a unity script to a behavior designer behavior tree so that I will not have to keep on going through this aggravation. Any help is greatly appreciated.
 
What type of variable is fleeSourceGameObject? Based on the error it looks like the variable is of type SharedString, but you are trying to assign a GameObject to it.
 
Justin,
FleeSourceGameObject is a SharedGameObject. The error says that but I have included the snippet of code that I am using that is the reason why the error makes no sense to me:

var fleeSourceGameObjectBT = (SharedGameObject)behaviorTreeVariables.behaviorTree.GetVariable ("fleeSourceGameObject");
fleeSourceGameObjectBT = behaviorTreeVariables.fleeSourceGameObject;
behaviorTreeVariables.behaviorTree.SetVariable ("fleeSourceGameObject", fleeSourceGameObjectBT);


public class BehaviorTreeVariables{

public BehaviorTree behaviorTree;
public SharedGameObject fleeSourceGameObject;

I am not setting a gameobject to a string. The only time that i use strings are in the GetVariable and SetVariable commands as specified by the documentation. I have included a screenshot in my previous that shows the fields. Thank you in advance for your cooperation.

I realized that it does not stop my program from running, so this might be an acceptable error.

The other reason why this error makes no sense is because the value that it is saying is in error is being correctly assigned to the field in the external behavior tree as illustrated by the screenshot.
 
justin,
how can i invoke the runtime source so that i can provide you with the information that you have requested?
 
You can import the runtime source which would then allow you to set breakpoints. Make sure you first remove the DLL version. Alternatively if you send a repro project to support@opsive.com I can take a look.
 
justin,
I was able to solve the issue without the runtime source. I think that the getVariable is what was the root cause. I now know that I do not have to do a getVariable before the setVariable. Thank you for your time.
 
sir,
the error reappeared and i loaded the runtime source and getting the following error:
TypeLoadException: Could not load type 'BehaviorDesigner.Runtime.Tasks.Movement.NavMesh Movement' from assembly 'BehaviorDesignerMovementAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MonoCustomAttrs.cs:108) System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) (at /Users

I am now completely dead in the water and behavior designer will not load it has a multitudinous amount of errors such as:
TypeLoadException: Could not load type 'UnityEditor.CurvePresetLibrary' from assembly 'UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Assets/Behavior Designer Movement/Scripts/GroupMovement.cs(5,43): error CS0246: The type or namespace name `Action' could not be found. Are you missing `System' or `Newtonsoft.Json.Serialization' using directive?

Assets/Behavior Designer Movement/Scripts/Tasks/CanSeeObject.cs(9,33): error CS0246: The type or namespace name `Conditional' could not be found. Are you missing an assembly reference?

Assets/Behavior Designer Movement/Scripts/Tasks/CanHearObject.cs(29,16): error CS0246: The type or namespace name `SharedVector3' could not be found. Are you missing an assembly reference?

and it keeps on going. how do I fix these errors so that I can get on with my project and meet my deadline? very urgent response required. I am beginning to regret loading the runtime source, I should have tried to figure it out myself. Thank you in advance for your cooperation.
 
Based on that error it doesn't look like you have the Behavior Designer task classes. I would completely remove the Behavior Designer folder and then reimport.
 
justin,
I did what you suggested before your reply and it did not recognize the tasks that I had in the movement pack(wander,move toward,etc). I also am restricted to an older version of behavior designer because of my project. I realized that the runtime source is not compatible with the version of behavior designer that I must use for my project, so I troubleshooted it myself and after 2 days of rebuilding my project the issue disappeared. i did change the preference from JSON to BINARY serialization, I do not know if that fixed it but, it had nothing to do with my code(i commented all code relevant to the behavior tree and still got the error) and everything to do with the behavior tree. I appreciate your response, but after hours of work I now am rid of that annoying error. Thank you in advance for your cooperation.
 
Top