Quote: "how so? like do a ray between the start pos and the hit pos? does SC_groupCollision() only tell you if two things are colliding, and not were they are colliding? easy fix I guess. Thanks."
This piece of code works with INTERSECT OBJECT , and
SC_rayCast works in the same way but faster.
autocam off
sync on
hide mouse
`making 10 objects to add as limbs to the main one
for i= 1 to 10
make object box i,40,2,40
position object i,rnd(100),rnd(100),rnd(100)
rotate object i,rnd(360),rnd(360),rnd(360)
make mesh from object i,i
next i
`making the final object to add all limbs
make object box 11,0,0,0
for i= 1 to 10
add limb 11,i,i
offset limb 11,i,object position x(i),object position y(i),object position z(i)
delete object i
next i
color object 11,rgb(200,0,200)
`intersect object
make object sphere 2,2:color object 2,rgb(255,0,0):set object radius 2,50
position camera -50,50,-50
do
set cursor 316,230
ink rgb(255,0,0)
print "."
`saving camera coords before moving
x#=camera position x()
y#=camera position y()
z#=camera position z()
`moving camera 1000 units and saving coords. after moving
move camera 1000
lx#=camera position x()
ly#=camera position y()
lz#=camera position z()
`moving camera back after saving coords.
move camera -1000
`distance is checked with both saved coords.
dis#= intersect object(11,x#,y#,z#,lx#,ly#,lz#)
`camera control.
control camera using arrowkeys 0,0.1,0.1
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
rotate camera cam#,a#,0
if leftkey() then move camera left 0.1
if rightkey() then move camera right 0.1
`positioning object 2 in camera coords and moving it the distance (dis)
position object 2,x#,y#,z#
rotate object 2,cam#,a#,0
move object 2,dis#
for i= 1 to 10
if limb collision(11,i,2,0)>0 then coll=i
next i
set cursor 225,10
ink rgb(255,255,0)
if dis#>0 then print "YOU PICK LIMB ",coll , " at distance:" ,dis#
set cursor 0,0
if intersect object(11,x#,y#,z#,lx#,ly#,lz#)
x= object position x(2) :print "point of collision X ",x: rem collision x
y= object position y(2) :print "point of collision Y ",y: rem collision y
z= object position z(2) :print "point of collision Z ",z: rem collision z
endif
turn#=turn#+0.03
rotate limb 11,1,0,turn#,0
sync
loop
I'm not a grumpy grandpa
