Can see Object throw me an error message

samuel.l

New member
Hi,
When I use Can see Object (or the Conditionnal Evaluation with Can be See) the behavior tree disappear and throw me this error message:

UnityException: NameToLayer can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
BehaviorDesigner.Runtime.Tasks.Movement.CanSeeObject..ctor () (at Assets/Behavior Designer Movement/Scripts/Tasks/CanSeeObject.cs:24)
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
....

when I use the Can be see from tutoriel, everything work fine.

Can you help me on this one?
 

Attachments

  • SampleScene_-_WIP_01_-_Android_-_Unity_2019_3_12f1_Personal__Personal___Metal_.jpg
    SampleScene_-_WIP_01_-_Android_-_Unity_2019_3_12f1_Personal__Personal___Metal_.jpg
    128.1 KB · Views: 4
You can just remove the NameToLayer assignment on line 24 so it just has:

Code:
public LayerMask ignoreLayerMask;
 
I had to change 49 lines too

" private int ignoreRaycastLayer;//= LayerMask.NameToLayer("Ignore Raycast");

public int IgnoreRaycastLayer { get => ignoreRaycastLayer; set => ignoreRaycastLayer = value; }
..."

and "Can see" seem to work now

but the problem still remain for "conditional evluator" >Mouvement>(... all)
 
.... I made the changes on "conditional evluator" >Mouvement>within and it's work now (sort of)

I fill the condition but the response is alway negative. Do you think it have something toi do with the code modification?
 
The problem isn't likely related to your modification. The easiest way to figure out what is going wrong is to place a breakpoint within Within Distance.OnUpdate and see where it is failing.
 
Top