Not sure which Action Manager applies to a condition I'm testing

Hey all,

I’ve been trying to add either a ValueCondition or a PredicateCondition to an action that I’m developing, such that said action can only be executed under the condition that I set. However, when I try to define the action (ExecuteCodeAction in this case) I get the following error:

Argument of type 'AbstractActionManager' is not assignable to parameter of type 'ActionManager'.
Type 'AbstractActionManager' is missing the following properties from type 'ActionManager': _scene, getScene, _getEffectiveTarget, _getProperty

The overall logic of my code is as follows:

  scene.actionManager = new BABYLON.ActionManager();

  let condition = true;

  const act = new BABYLON.ExecuteCodeAction(
          trigger: BABYLON.ActionManager.OnKeyDownTrigger,
          parameter: "r"
      () => {
          //code to execute when action "r" is pressed
      new BABYLON.PredicateCondition(scene.actionManager,
      () => {return condition;})

I replicated the issue in this Playground, where I tested both the sphere’s and scene’s actionManagers, to no avail. It seems like both of these are declared as AbstractActionManagers? The examples here don’t seem to address the declaration for the ActionManager, so I’m at a loss.

Any help will be appreciated!

1 Like

Oh, typescript typings! :slight_smile:

Well, typescript is right! PredicateCondition takes an action manager, and scene.actionManager is an abstract action manager, even if you assign an action manager to it.

One fix would be this:

Condition Testing | Babylon.js Playground (

Another fix would be this:

Condition Testing | Babylon.js Playground (

You will have the same when trying to change properties in mesh.material. Even if you set it to a standard material, it is still a different type and the standard material properties will not be shown (though they will be there). That’s how typescript works, and we love it :slight_smile:


Oh, and sorry for not directly answering your question. There are reasons behind defining them as an abstract action manager. if you want to say that it makes sense to accept an abstract action manager when using the PredicateCondition, i would say you are probably right (without looking at each use-case, because this condition might be using the ActionManager’s proeprties, that don’t exist in AbstractActionManager)

Thank you Raanan! The typecasting worked wonderfully. I did not think I could actually typecast it to fix the issue, so definitely cleared up more than one doubt from that fix.