Camerapick Problem
Blitz3D Forums/Blitz3D Beginners Area/Camerapick Problem
| ||
I have problem with the camerapick function. I wrote this code: If mousehit(1) camerapick(camera,mousex(),mousey()) positionentity pgopoint,pickedx#(),-25,pickedz#() end if And everywhere i am clicking it's positioning it on 0,-25,0 Why??? (sorry about my english if there is problam with her) |
| ||
Description Picks the entity positioned at the specified viewport coordinates. Returns the entity picked, or 0 if none there. An entity must have its EntityPickMode set to a non-0 value value to be 'pickable'. |
| ||
Thanks for the quick reply, but is there any way that i would know where i clicked on the viewport? I am trying to create a strategy game using mouse to move the player. so what i was trying do is to place a sphere on the viewport and then using point entity to the character and moving him to the sphere. is there a way tot do that? (again sorry about my english) |
| ||
try something like thisGraphics3D 640,480,32,0 SetBuffer BackBuffer() camera=CreateCamera() terreno=CreatePlane() pla=CreateCube() EntityColor pla,255,0,0 lit=CreateLight() PositionEntity lit,10,10,10 PositionEntity pla,0,2,0 PositionEntity camera,0,5,-8 PointEntity camera,pla EntityPickMode terreno,2 pivot_target=CreatePivot() Repeat Cls If MouseHit(1) CameraPick(camera,MouseX(),MouseY()) pick=PickedEntity() If pick=terreno move=1 tx#=PickedX() ty#=PickedY() tz#=PickedZ() PositionEntity pivot_target,tx#,ty#,tz# PointEntity pla,pivot_target Else move=0 End If End If If move=1 MoveEntity pla,0,0,.1 ;here you need to check the movement / the reaching of target of pla End If UpdateWorld RenderWorld Flip Until KeyDown(1) End the above example doesn't check if the player reach the destination, you can use EntityDistance to do this. Hope this helps byez |
| ||
Where you click on the viewport, will be the mouseX and mouseY co-ords. |