mesh.setAbsolutePosition not change mesh position

Hi,
I’m trying to set the position of a loaded mesh (exported from blender 2.8), but it stays at the same position 0,0,0. I use mesh.setAbsolutePoistion(otherVector3), but the mesh not update its position.

I’ve searched for a answer without sucess. I use the SceneLoader.ImportMeshAsync to load the meshes and I get one to be the player, and that don’t move.

I’m forgetting to do something?

Hey, we will need to see the mesh and the scene
can you load your asset in the pg?

Man, I don’t know how to setup the scene at the PG, but my code from set the player mesh, is just:

  const view = document.getElementById("view") as HTMLCanvasElement;
  const engine = new Engine(view, true);
  const scene = new Scene(engine);
  BABYLON.SceneLoader.ImportMeshAsync(null, "https://raw.githubusercontent.com/cpusam/cpusam.github.io/master/tux/", "TUX.rEMESHblend.babylon", scene)
.then((result) => {
  let playerMesh = result.meshes.find(m => m.name === "playerTux");
  //now add the mesh to player 
  //and finally, add the player.update() at the registerBeforeRender
  //this update is where the player move, just a position.x += 0.05
  //and before quit update, it do playerMesh.setAbsolutePosition(this.position);
});

well as you can imagine this does not help me helping you

1 Like

hahaha ok man, I don’t have some time free, because it’s monday and I was working.
But, maybe at the saturday I will prepare to you a full minimal source to you help me.
So, just wait a little. And if you have some ideia, share here.

Even at work if you ask for help it’s often worth to spend time for it, you will be more efficient once answered :wink:

If you had read the doc’ above, you could have notice that you just had to change the mesh url from the playground example of using raw.githubusercontent.com part.

Anyway, I don’t see any issue about the absolutePosition tweaking of your Tux, try to edit this playground to show us your code: https://www.babylonjs-playground.com/#YIU90M#178

1 Like

There is one way that this will happen that, while unlikely, will be very difficult to find. There is a freezeworldmatrix custom Blender property. If that was checked, it will not move, because you asked it not to.

The two most likely reasons are:

  • a spelling error on the function name, just like you did in the first post.
  • Your code for getting mesh is flawed. I use scene.getMeshById(). To rule out, run the dispose() method. If still there, then this is the problem.

I shouldn’t have to say it, but check the console too.

@Vinc3r
Wow, man, I will look at my code to see where I’m doing wrong.

@JCPalmer
Thanks for the info!

I now know why my code was wrong, I was setting the mesh with name “playerTux” and not the true mesh of name “TUXrEMESH3”.
Thanks for the code!

1 Like