Quote: "i couldn't get it work."
probably because the command "SC_raycast" is a function from an external plugin, and DBPro recognizes the command as a reference to an array if you don't have the plugin installed.
Generally, there are two methods of selecting units. If you have a bumpy terrain, going up and down and every which way, then you really should use that SC_raycast command (SC stands for Sparky's Collision). However, if you just have a plane, then you can use simpler math to figure out where your mouse is clicking. Here's some code that does just that:
make matrix 1,100,100,10,10
make object sphere 1,1
position camera 0,20,0
point camera 50,0,50
do
select_location()
sync
loop
function select_location()
null = make vector3(1)
null = make vector3(2)
null = make vector3(3)
set vector3 1, 0, -1, 0
pick screen mousex(), mousey(), 1
set vector3 2,get pick vector x(),get pick vector y(),get pick vector z()
hypo_length# = camera position y()/ dot product vector3(2,1)
normalize vector3 2,2
scale vector3 2,2, hypo_length#
set vector3 1, camera position x(), camera position y(), camera position z()
add vector3 3, 1, 2
`vector number 3 is now the point that your mouse click intersects the plane.
position object 1, x vector3(3), 0, z vector3(3)
null = delete vector3(1)
null = delete vector3(2)
null = delete vector3(3)
endfunction
raycasting is easier, and allows for odd shaped terrain, but math stuff works just as well for flat planes. If you want to know exactly what all that math is doing, i strongly suggest you take a look at this tutorial:
http://www.neurofuzzydev.com/V/D/index.htm
called "Vectors Don't Bite!"
[edit]
wait wait wait I think i totally misunderstood the problem...
Is something like this more what you're looking for?
make matrix 1,100,100,10,10
make object sphere 1,1
make object cube 2,2
position camera 0,20,0
point camera 50,0,50
do
point object 2,object position x(1),0,object position z(1)
move object 2,.01
select_location()
sync
loop
function select_location()
null = make vector3(1)
null = make vector3(2)
null = make vector3(3)
set vector3 1, 0, -1, 0
pick screen mousex(), mousey(), 1
set vector3 2,get pick vector x(),get pick vector y(),get pick vector z()
hypo_length# = camera position y()/ dot product vector3(2,1)
normalize vector3 2,2
scale vector3 2,2, hypo_length#
set vector3 1, camera position x(), camera position y(), camera position z()
add vector3 3, 1, 2
`vector number 3 is now the point that your mouse click intersects the plane.
position object 1, x vector3(3), 0, z vector3(3)
null = delete vector3(1)
null = delete vector3(2)
null = delete vector3(3)
endfunction