ok so im trying to make a simple program to make an object below where the cursor object is.the object placed will be aligned with the plain(this will be replaced with a terrain later)
you need to press the "r" key after each click to reset it(i don't have a timer system yet) or hold it down to make a one every loop.
but the hit points of the cast are always at like 1.23...,0,0
so what am i doing wrong?
// basic setup
sync on :sync rate 0 : autocam off
//make our object that is going to be instanced
make object cube 11,10
`load object "C:\Program Files\The Game Creators\FPS Creator\Files\entitybank\Nature\grass1.x",11
`set object transparency 11,4
`hide object 11
//start Dark Physics
phy start
//make our groung object
make object box 100,100,1,100
//add our ground object to the simulatuon as a static box
phy make rigid body static box 100
//make the cursor object
make object sphere 1,2
remstart
global a as float
global b as float
global c as float
global d as float
global vx as float
global vy as float
global vz as float
global dy as float
remend
//position camera so we can see the scene better
position camera 0,50,100 : point camera 0,0,-5
//start the d3d plugin
d3d_init
do
//print info on the screen
d3d_starttext
d3d_text 1,0,0,0,"FPS "+str$(screen fps())
d3d_text 1,0,20,0,"x hit "+str$(r_hit_x#)
d3d_text 1,0,40,0,"y hit "+str$(b#)
d3d_text 1,0,60,0,"z hit "+str$(c#)
d3d_text 1,0,80,0,"hit dist "+str$(d#)
d3d_text 1,0,100,0,"obj hit num "+str$(e#)
d3d_text 1,0,120,0,"obj hit "+str$(ray_hit)
d3d_endtext
//camera movement
control camera using arrowkeys 0 ,1,1
//position mouse marker
pick screen mousex(),mouseY(),1000
vx# = get pick vector x()
vy# = get pick vector y()
vz# = get pick vector z()
dy# = -camera position y()/vy#
vx# = vx#*dy# + camera position x()
vz# = vz#*dy# + camera position z()
position object 1,vx#,dy#+ 2,vz#
//start the raycast pointing down in the cursor objects position
value = phy ray cast all shapes ( object position x(1),object position y(1),object position z(1), 0, -1, 0 )
//see if we have hit anything
ray_hit = phy get ray cast hit( )
//if we are clicking and its been reset with r and ray_hit is 1
//the reason im using the primitive "reset" is because i havent made a timer system yet(going to solve this first)
if mouseclick() = 1 and click = 0
if phy get ray cast hit( )= 1
//get ray info
r_hit_x# = PHY GET RAY CAST HIT point X()
b# = PHY GET RAY CAST HIT point y()
c# = PHY GET RAY CAST HIT point z()
d# = phy get ray cast distance()
e# = phy get ray cast object()
//get a object number thats not used
w = freeobject()
//make a instance of our object
instance object w,11
//position the object at the raycast hit points
position object w, r_hit_x#,b#,c#
//randomly rotate the object
rotate object w,0,rnd(360),0
//declare that the mouse has been clicked
click = 1
endif
endif
//reset the click
if inkey$() = "r"
click = 0
endif
phy update
//update the simulatuon
sync
//update the screen
loop
function FreeObject()
repeat
inc i
if object exist(i)=0 then found=1
until found
endfunction i
Thanks for you time
E.S.