MouseOver does not correspond to mesh deformed by armatures


There seems to be a problem with the ‘mouseOverAny’ sensor in the Game Engine.

This is the setup:

  • A mesh is deformed/controlled by an armature
  • The armature has actions or is controlled by IK targets (doesn’t really matter)
  • The mesh visually deforms in Game mode*
  • This rules out the common error of not ‘running’ the armature through an Always/And/RunArmature.

If you add a mouseOver sensor to the game (through Python or logic bricks), it is using the original mesh position instead of the deformed one. So sometimes the sensor reports ‘None’ while the mouse is clearly on the deformed mesh, while other times it reports ‘MeshName’ while it is not on the mesh…

Here’s an example blend:

It shows a deformed mesh, tracking a sphere. The script outputs the name of the object detected by mouseOver. As you can see, it often says ‘Plane’ when the mouse is actually over the cube.

Is this a bug, a feature, or something I did wrong?

The Action actuator deforms the display mesh (GFX) only.
The Physics mesh (phys) remains as it was.

Switch on Physics Visualization at the Game menu to see this effect.

Rays/collisions always work with the physics mesh.

You can call the function reinstancePhysicsMesh to update the physics mesh. Be aware this is a performance intensive task.

That is no bug.
When you deform a mesh with an armature then only the visual mesh is deforming. The physic mesh will not deformed, is still the same as on game engine startup.
You can see that when you enable in the menu bar under “Game” the “Show Physic Visualization”.

You need to re-instance the physic mesh with a Always(true puls)/And/Edit Object --> Replace Mesh (GfX off; Phys on).

Or you use python script and use reinstancePhysicsMesh(object, mesh).

But re-instancing the physic mesh is very slow.

Monster was fasert then I.

Thanks for the clear answers, I was sort of expecting something like this :frowning: I’ll check if the mesh re-instance method is workable, but as you said it’s probably going to slow down the whole thing.

no way! you can update the physics mesh by using the replace mesh actuator??

@mrn Yes that works. Download the the test file from post #3.

sweet thanks i tried it out in a new blend and it works great!

The impact on performance/speed is not as bad as expected by the way (and in my case the updates are restricted to certain actions, not every frame or second). Thanks for the info!