I'm using BabylonJS to make a small game and i wan't to atach a block to my camera.
The code is :
block.parent = camera;
It's working, but now i wan't the block to follow my camera with a difference of 5 pixels on the X axe for exemple.
How can i add 5 pixels ton the X axe ?
This code don't work :
block.position = new BABYLON.Vector3(5, 0, 0);
block.parent = camera;
The code you submitted should be working. You set the position relative to the parent object and then attach it to the parent.
You can see a live example here - http://www.babylonjs-playground.com/#2BOTII . The ground's position is the camera's position + the relative position.
If you set the ground's position to 0 you won't see the ground, as it is exactly at the camera's viewing height.