# Action manager is null

**URL:** <https://forum.babylonjs.com/t/action-manager-is-null/39909>\
**Category:** Questions\
**Created:** [April 15, 2023, 7:18am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909 "2023-04-15T07:18:28Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![icy\_director](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/icy_director/32/30525_2.png) [@icy\_director](https://forum.babylonjs.com/u/icy_director)\
**Post date:** [April 15, 2023, 7:18am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/1 "2023-04-15T07:18:28Z")

</div>

I am trying to trigger hover event over mesh. I saw that action manager would be solution but I get this error while trying to use it:  
**cannot set properties of null (setting ‘actionManager’)**

here is what I wrote:

```auto
 const mesh = scene.getMeshById(mesh);

    mesh.actionManager = new BABYLON.ActionManager(scene);

    var hl = new BABYLON.HighlightLayer('hl1', scene, {
      isStroke: true,
    });

    //ON MOUSE ENTER
    mesh.actionManager.registerAction(
      new BABYLON.ExecuteCodeAction(
        BABYLON.ActionManager.OnPointerOverTrigger,
        function (ev) {
          scene.hoverCursor = 'pointer';
          hl.addMesh(mesh, BABYLON.Color3.Green());
        }
      )
    );

```

Basically I copied it from here [https://www.babylonjs-playground.com/#21YCLG#61](https://www.babylonjs-playground.com/#21YCLG#61)

---

<div class="post-metadata">

**Author:** ![CodingCrusader](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/codingcrusader/32/29857_2.png) [@CodingCrusader](https://forum.babylonjs.com/u/CodingCrusader)\
**Post date:** [April 15, 2023, 7:22am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/2 "2023-04-15T07:22:08Z")

</div>

> [@icy\_director](#):
>
> `const mesh = scene.getMeshById(mesh);`

It seems to me that there is something wrong with the parameter… It should not be the ID of the mesh you are looking for?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 15, 2023, 7:34am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/3 "2023-04-15T07:34:38Z")

</div>

If you know mesh ID, it should be like (in TS):

```auto
scene.getMeshById(id:number);

```

Another option, if you don’t know mesh ID, to get it by its name (as in PG):

```auto
scene.getMeshByName(meshname:string)

```

---

<div class="post-metadata">

**Author:** ![icy\_director](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/icy_director/32/30525_2.png) [@icy\_director](https://forum.babylonjs.com/u/icy_director)\
**Post date:** [April 15, 2023, 7:39am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/4 "2023-04-15T07:39:33Z")

</div>

The problem is that I already use it in my code and it works fine. But now my scene object is differente. On console log on line 162 scene object has meshes:Array(7)  
On console log on line 253 scene object has meshes:Array(0)

So this would be the reason for getting null, but since I already have used it I am not sure why is my scene object differente.

[Here is what I have.](https://github.com/petrovic23/sim/blob/main/src/Components/Babylon/MyController.js)

---

<div class="post-metadata">

**Author:** ![icy\_director](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/icy_director/32/30525_2.png) [@icy\_director](https://forum.babylonjs.com/u/icy_director)\
**Post date:** [April 15, 2023, 8:11am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/5 "2023-04-15T08:11:08Z")

</div>

Is there an event which I can use on pointer move over mesh?  
Now I get results only when I enter the mesh.

---

<div class="post-metadata">

**Author:** ![CodingCrusader](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/codingcrusader/32/29857_2.png) [@CodingCrusader](https://forum.babylonjs.com/u/CodingCrusader)\
**Post date:** [April 15, 2023, 8:23am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/6 "2023-04-15T08:23:56Z")

</div>

The example you gave with OnPointerOverTrigger works fine. I am not sure what this.\_store[‘enabledMesh’] returns, never used it, but I suppose it is the mesh which was enabled if you clicked on it?

If I were you, I would try to debug the Javascript Code and find out the difference between the scenes. Return to the scene where everything is fine, then modify your code step by step until it is not working and look what is here unusual in the values or function call stack.

---

<div class="post-metadata">

**Author:** ![icy\_director](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/icy_director/32/30525_2.png) [@icy\_director](https://forum.babylonjs.com/u/icy_director)\
**Post date:** [April 15, 2023, 8:34am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/7 "2023-04-15T08:34:05Z")

</div>

enabledMesh is id from a mesh, that’s why I use id.  
Before I do it I have another question.  
How can I get pickInfo on cursor moving over mesh?  
Action manager has over and out. Which works fine when I enter, but doesnt do anything while moving.  
I tried onPointerMove but it doesnt return the coordinates of the cursor nor anything about mesh. I am looking for an object like pointerInfo in scene.onPointerObservable.add((pointerInfo) =\> {} where I can get normal, face and position.  
I want to hover and place decal there, just like click.

---

<div class="post-metadata">

**Author:** ![CodingCrusader](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/codingcrusader/32/29857_2.png) [@CodingCrusader](https://forum.babylonjs.com/u/CodingCrusader)\
**Post date:** [April 15, 2023, 8:36am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/8 "2023-04-15T08:36:34Z")

</div>

```auto
var pickinfo = scene.pick(scene.pointerX, scene.pointerY, function (mesh) { return mesh == ground; });
if (pickinfo.hit) {
 return pickinfo.pickedPoint;
}

```

---

<div class="post-metadata">

**Author:** ![CodingCrusader](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/codingcrusader/32/29857_2.png) [@CodingCrusader](https://forum.babylonjs.com/u/CodingCrusader)\
**Post date:** [April 15, 2023, 8:42am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/9 "2023-04-15T08:42:27Z")

</div>

To make code understandable for others, you should use names for variables and functions due to the [Style Guide](https://www.w3schools.com/js/js_conventions.asp)

e.g. if “mesh” is not a mesh object but a number (ID) then you shall use “meshID” … but even this is a bad style… because what sort of meshID is this for? Is it a targetMeshID or a sourceMeshID or a tempMeshID … If an other person reads your code he or she shouldn’t seek for the meaning of a variable or a function… it should be self explanativ.

Just a good advice of an old rabbit 😉

---

<div class="post-metadata">

**Author:** ![icy\_director](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/icy_director/32/30525_2.png) [@icy\_director](https://forum.babylonjs.com/u/icy_director)\
**Post date:** [April 15, 2023, 8:51am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/10 "2023-04-15T08:51:12Z")

</div>

Thanks you rabbit, I havent been thinking about it.  
Everythink is working.

---

<div class="post-metadata">

**Author:** ![icy\_director](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/icy_director/32/30525_2.png) [@icy\_director](https://forum.babylonjs.com/u/icy_director)\
**Post date:** [April 15, 2023, 9:33am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/11 "2023-04-15T09:33:02Z")

</div>

I have a quick question.  
Setting alpha property just adds background to it.  
Am I able to set opacity to a decal?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [April 15, 2023, 9:59am UTC](https://forum.babylonjs.com/t/action-manager-is-null/39909/12 "2023-04-15T09:59:57Z")

</div>

You may try to use texture decals, also known as decal maps - [Decals | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/mesh/decals#texture-decals-or-decal-maps)
