how to get position of entity
Blitz3D Forums/Blitz3D Beginners Area/how to get position of entity
| ||
hi, want to ask something here. how do i get the exact position of an entity? i am trying to place a sprite in the middle of an entity. The entity is moving, so when the player hits a button, the sprite will show up in the middle of the entity. I have tried entityx, y, z, but the position is not correct. thanks alot! |
| ||
You're probably moving the entity after getting the entity position. IE. x = entityx(entity) y = entityy(entity) z = entityz(entity) moveentity entity 10,10,10 positionentity sprite,x,y,z As opposed to moveentity entity 10,10,10 x = entityx(entity) y = entityy(entity) z = entityz(entity) positionentity sprite,x,y,z |
| ||
In addition to what Rob said, if the entity you're trying to find the position of is parented to another entity, then you'll need to use the global parameter in EntityX/Y/Z. |
| ||
i tried placing an entity (a cube) at 0,0,0 using positionEntity command. When i run the scene, the cube appears in front of the camera. but when i create a sprite and position it at 0,0,0 it doesn't shows up in the scene. is 2d sprite positioning different from 3d entity? |
| ||
No. |
| ||
The sprite is probably inside the cube... change the sprites position to 2,0,2 or something... 4,0,4... then take a look. RZ |
| ||
x#=EntityX#(cube,True) y#=EntityY#(cube,True) z#=EntityZ#(cube,True) Make sure you use Floats in case the position of an entity is not at an exact integer of units along an axis. Plus, ensure its the global position you are checking. Finally, the actual meshes have a 'handle' point, which is what 'part' of the mesh is actually placed at that location. If this 'handle'point is offset from the mesh's centre, then the mesh wont appear to be at that location, but slightly transposed. _______________________________________________________ Edited as per GFK's suggetion below (Thanks!) |
| ||
x#=EntityX#(cube,1) y#=EntityY#(cube,1) z#=EntityZ#(cube,1) Make sure you use Floats in case the position of an entity is not at an exact integer of units along an axis. Plus, ensure its the global position you are checking. I would strongly recommend using True and False instead of 1 and 0, to help readability. |