Entity.setPosition has no effect..?

Hello!
Further into my development of my voxel game, I hit an unusual situation.
Thanks to everyone’s help, I figured out how to render the voxels (and even add collisions). But, for some reason I am not able to position the entities that I procedurally create. So, I can MAKE the terrain, but I cannot MOVE it.

In game.js you will see the code. It is the first few lines in the createChunk() function that you will see this all play out. How come the entity will not move? I try to make multiple chunks in the initialize() function but it only seems to make one.

Thank you for any help.

Project:
https://playcanvas.com/editor/scene/1439135

Hi @Kurios,

You can’t use setPosition on an entity that has a static/dynamic rigidbody component. You should be using the rigidbody.teleport() method for dynamic rigid bodies.

For static rigid bodies you should can use setPosition before you add the rigid body component. If you would like to move it at a later point, you should disable the rigid body component, set the position of the entity and re-enable:

entity.rigidbody.enabled = false;
entity.setPosition(newPosition);
entity.rigidbody.enabled = true;
1 Like

Thank you for responding @Leonidas, however the odd thing is that I am doing that:

Lines 26 & 28 in game.js:

    var entity = new pc.Entity();

    entity.setPosition(pos.x, 0, pos.y);

Hi @Kurios! I forked your project to be able to debug it. Please check the result below.

image
image