Not a Bug

InvalidOperationException: Missing target object With custom script

Hazukiaoi 3 years ago updated by Julio Pereira 2 months ago 7

I Create a class TestBoltFunc


using UnityEngine;
public class TestBoltFunc : MonoBehaviour
    public void TestFunction()

    public float TestFuncPama(float start)
         return start + 2;

and make the node in flow

when i run will error

like it:

InvalidOperationException: Missing target object for 'TestBoltFunc.TestFunction'.
Ludiq.Member.EnsureReady () (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Reflection/Member.cs:760)
Ludiq.Member.EnsureInvocable () (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Reflection/Member.cs:844)
Ludiq.Member.Invoke () (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Reflection/Member.cs:877)
Bolt.InvokeMember.Invoke (Bolt.Flow flow) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Flow/Runtime/Framework/Codebase/InvokeMember.cs:166)
Bolt.InvokeMember.Enter (Bolt.Flow flow) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Flow/Runtime/Framework/Codebase/InvokeMember.cs:250)
Bolt.Flow.InvokeDelegate (Bolt.ControlInput input) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Flow/Runtime/Flow.cs:399)
Bolt.Flow.Invoke (Bolt.ControlOutput output) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Flow/Runtime/Flow.cs:293)
Bolt.Flow.Run (Bolt.ControlOutput port) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Flow/Runtime/Flow.cs:229)
Bolt.EventUnit`1[TArgs].Run (Bolt.Flow flow) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Flow/Runtime/Framework/Events/EventUnit.cs:152)
Bolt.EventUnit`1[TArgs].Trigger (Ludiq.GraphReference reference, TArgs args) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Flow/Runtime/Framework/Events/EventUnit.cs:123)
Bolt.XEventGraph.TriggerEventHandler[TArgs] (Ludiq.GraphStack stack, System.Func`2[T,TResult] predicate, TArgs args, System.Func`2[T,TResult] recurse, System.Boolean force) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.Core/Runtime/Events/IEventGraph.cs:48)
Bolt.FlowState.OnEnterImplementation (Bolt.Flow flow) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.State/Runtime/FlowState.cs:23)
Bolt.State.OnEnter (Bolt.Flow flow, Bolt.StateEnterReason reason) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.State/Runtime/State.cs:147)
Bolt.StateGraph.Start (Bolt.Flow flow) (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.State/Runtime/StateGraph.cs:120)
Bolt.StateMachine.OnEnable () (at C:/Users/lazlo/Projects/Bolt1/Package/Bolt.State/Runtime/StateMachine.cs:17)
Bolt Version:
Unity Version:
Unity 2018.4.0f1
Scripting Backend:
.NET Version (API Compatibility Level):

OK, I not put the script to Object

Not a Bug

Glad you figured it out!

Also, if you don't need an instance for the script, just make the method or class static.


can u little explain it. I also get same problem.

you must add your script to the object with Flow Machine component


What did you mean with " I not put the script to Object"? Can u explain please?c:

For everyone who runs into this issue and comes across this while googling the solution is as follows:

You need to attach the script to a GameObject otherwise that script isn't activated. So for an example lets say you have the following:

  • Sound_Manager - Has Flow Macro (FM: Has a bunch of checks and other fun before SFXs are run)
  • SFX_Button_Cool - Button with Flow Macro (FM: Does something cool on top of saying "Cool")
  • SFX_Button_Neat - Button with Flow Macro (FM: Just says "Neat")

Now if the script you've made is needed by all SFX buttons it would be best to attach it to the Sound_Manager GameObject by dragging and dropping the C# Script onto the Inspector window under the Flow Machine/Empty space next to Add Component. This way the script is only activated once and/or if you have something that calls Update a lot its only done in the Sound_Manager and not each button. 

If however the C# Script was to ONLY make the SFX_Button_Cool do crazy fancy stuff in your program then you would attach the script there because you'd only want it to be activated if the user clicked on that button.

To sum this all up, attach the C# Script to a GameObject so the script can be activated. If the code is being accessed by several places in your program, activate the script in a location that is accessed before anything that needs to reference it tries to.

Thankx. I was with this problem too. I can understand now!