Here is an example
if ( GetPointerPressed() )
local distance as float
local directionX as float
local directionY as float
local directionZ as float
distance = 1500.0
directionX = Get3DVectorXFromScreen( GetPointerX(), GetPointerY() ) * distance + GetCameraX(1)
directionY = Get3DVectorYFromScreen( GetPointerX(), GetPointerY() ) * distance + GetCameraY(1)
directionZ = Get3DVectorZFromScreen( GetPointerX(), GetPointerY() ) * distance + GetCameraZ(1)
HitObjID = ObjectRayCast( 0, GetCameraX(1), GetCameraY(1), GetCameraZ(1), directionX, directionY, directionZ )
if HitObjID > 0
PickVec = CreateVector3( GetObjectRayCastX( 0 ), GetObjectRayCastY( 0 ), GetObjectRayCastZ( 0 ) )
//Add your code here for what you want to do to object.
endif
endif
The coffee is lovely dark and deep,and I have code to write before I sleep.