looks useful too bad I did not see this sooner and made my own.
createobjectbox(1,100,100,100)
movecameralocalz(1,-300)
createobjectbox(2,5,5,5)
setobjectcolor(2,255,0,0,255)
do
worldX# = Get3DVectorXFromScreen( GetPointerX(), GetPointerY() ) * 800
worldY# = Get3DVectorYFromScreen( GetPointerX(), GetPointerY() ) * 800
worldZ# = Get3DVectorZFromScreen( GetPointerX(), GetPointerY() ) * 800
worldX# = worldX# + GetCameraX( 1 )
worldY# = worldY# + GetCameraY( 1 )
worldZ# = worldZ# + GetCameraZ( 1 )
obj=ObjectRayCast(1,getcamerax(1),getcameray(1),getcameraz(1), worldx#,worldy#,worldz#)
if obj
x as float
y as float
z as float
x=GetObjectRayCastX(0)
y=GetObjectRayCasty(0)
z=GetObjectRayCastz(0)
setobjectposition (2,x,y,z)
print ("object: "+str(obj))
print ( "X: "+str(x) )
print ( "Y: "+str(y))
print ( "Z: "+str(z))
endif
sync()
loop
It is useful because you can get the position where you clicked on the object.
You could make a top down placement system like rts with this:
global aicount
aicount=3
createobjectplane(1,100,100)
movecameralocalz(1,-300)
createobjectbox(2,5,5,5)
setobjectcolor(2,255,0,0,255)
do
worldX# = Get3DVectorXFromScreen( GetPointerX(), GetPointerY() ) * 800
worldY# = Get3DVectorYFromScreen( GetPointerX(), GetPointerY() ) * 800
worldZ# = Get3DVectorZFromScreen( GetPointerX(), GetPointerY() ) * 800
worldX# = worldX# + GetCameraX( 1 )
worldY# = worldY# + GetCameraY( 1 )
worldZ# = worldZ# + GetCameraZ( 1 )
obj=ObjectRayCast(1,getcamerax(1),getcameray(1),getcameraz(1), worldx#,worldy#,worldz#)
if obj
x as float
y as float
z as float
x=GetObjectRayCastX(0)
y=GetObjectRayCasty(0)
z=GetObjectRayCastz(0)
setobjectposition (2,x,y,z)
if getpointerpressed()
createobjectbox(aicount,5,5,5)
setobjectposition(aicount,x,y,z)
setobjectcolor(aicount,0,255,0,255)
aicount=aicount+1
endif
print ("object: "+str(obj))
print ( "X: "+str(x) )
print ( "Y: "+str(y))
print ( "Z: "+str(z))
endif
sync()
loop