# ActionManager best practices

**URL:** <https://forum.babylonjs.com/t/actionmanager-best-practices/31850>\
**Category:** Questions\
**Created:** [July 1, 2022, 5:22pm UTC](https://forum.babylonjs.com/t/actionmanager-best-practices/31850 "2022-07-01T17:22:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericwood73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ericwood73/32/22967_2.png) [@ericwood73](https://forum.babylonjs.com/u/ericwood73)\
**Post date:** [July 1, 2022, 5:22pm UTC](https://forum.babylonjs.com/t/actionmanager-best-practices/31850/1 "2022-07-01T17:22:22Z")

</div>

I have several meshes that I want to attach actions to. Normally you would use an actionmanager per mesh as the registered actions are triggered for every mesh attached to the same actionmanager instance. However, I want to be able to set properties across all action managers, such as isRecursive and hoverCursor. So I force every mesh to use the same action manager instance. This in turn requires a unique action to be registered for each mesh that contains a predicate to verify that the picked mesh is the one associated with the edit action. The alternative would be to iterate over all meshes unique action manager instances and set the hoverCursor. My question is which approach, if either is more consistent with the expected use of actions:

1. Each mesh should have a unique action manager instance and any values to be set on all mesh actionManagers should be done via an observer for each or keeping the action managers in a list and iterating them all to set properties
2. Having a single action manager instance shared across all meshes with a unique set of actions for each mesh that contain a predicate to test that the action was directed at that mesh.  
I suspect that it doesn’t matter, but I want to confirm. The documentation seems to imply a unique action manager instance for each mesh.

---

<div class="post-metadata">

**Author:** ![ericwood73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ericwood73/32/22967_2.png) [@ericwood73](https://forum.babylonjs.com/u/ericwood73)\
**Post date:** [July 1, 2022, 5:32pm UTC](https://forum.babylonjs.com/t/actionmanager-best-practices/31850/2 "2022-07-01T17:32:14Z")

</div>

It occurred to me in the case of #2 that every time a trigger occurs it would check the predicate condition for each action for each mesh, so maybe it is more efficient to use individual action managers as in #1 (although we aren’t expecting hundreds of meshes so the performance difference may be minor)?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 4, 2022, 5:51pm UTC](https://forum.babylonjs.com/t/actionmanager-best-practices/31850/3 "2022-07-04T17:51:26Z")

</div>

I agree that approach #1 would be more efficient, but yeah, if there aren’t too many meshes then this wouldn’t matter much 🤔 @Deltakosh any thoughts on this?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 5, 2022, 4:30pm UTC](https://forum.babylonjs.com/t/actionmanager-best-practices/31850/4 "2022-07-05T16:30:58Z")

</div>

Yes I do agree as well. #1 is far better

---

<div class="post-metadata">

**Author:** ![ericwood73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ericwood73/32/22967_2.png) [@ericwood73](https://forum.babylonjs.com/u/ericwood73)\
**Post date:** [July 5, 2022, 5:10pm UTC](https://forum.babylonjs.com/t/actionmanager-best-practices/31850/5 "2022-07-05T17:10:57Z")

</div>

Thank you. Will proceed as you recommend.
