How to find current position of camera

Blitz3D Forums/Blitz3D Beginners Area/How to find current position of camera

How do I find the current position of the camera during game play, does anyone have any idea how that could be done? I just need the position to show up on the screen when you click a key, or something like that...
Any help would be apreciated, Thanks!

X# = EntityX( camera)
Y# = EntityY( camera)
Z# = EntityZ( camera)


graphics 3d,800,600,0,2
camera=createcamera()
;mesh = loadmesh("some test environment")
repeat


if keydown(200) then moveentity camera,0,0,1  ;move forwards on pressing up arrow
if keydown(208) then moveentity camera,0,0,-1 ;move backwards on pressing down arrow
if keydown(30) then moveentity camera,0,1,0 ;move camera up if A pressed
if keydown(44) then moveentity camera,0,-1,0 ;move camera down if Z pressed
if keydown(203) then turnentity camera,0,1,0 ;turn left on left arrow key pressed
if keydown(205) then turnentity camera,0,-1,0 ;turn right on right arrow key pressed

updateworld
renderworld
text 0,0,entityx(camera,true)
text 0,15,entityy(camera,true)
text 0,30,entityz(camera,true)
flip


until keydown(1)
freeentity camera
end




something like that should help hopefully.

Both did not work...
The first one I tried made no sense to me...

The second one looked promising, but When I used it, it didn't work... Does the code print the location of the camera on the screen? Or is there something I'm Missing?

exactly as mr, Bilip show ya..
X# = EntityX( camera)
Y# = EntityY( camera)
Z# = EntityZ( camera)

these are coordinates for your camera, now..you should make your camera globaly accessible ( Global Camera=Createcamera() ) and of course, in example above i assume that your camera entity has name 'camera' as it is in example..if not, use proper camera handler name, accessible globaly

For Matty's example, change the first line
graphics 3d,800,600,0,2

to this

graphics3d 800,600,0,2

Thank you Pongo for clearing that, It works nicely now! I'm going to stick with it. Thanks. ☺

Just ensure your camera is given a global variable :o)