You could check for a collision and once that has occurred, you could check against the limb locations using vector3.
A rough example:
sync on
sync rate 60
randomize timer()
hide mouse
color backdrop rgb(0,80,200)
autocam off
global speed# as float : speed# = 0.5
global chardistance# as float : global dist# as float
global ClosestLimb as integer
Global TotalLimbs as integer
` make floor
make object box 10,1000,10,1000
position object 10,0,-15,0
color object 10,rgb(0,255,45)
` make man with primatives
make object sphere 1,4
head = 1
make mesh from object head,1
delete object 1
make object cylinder 1,4
scale object 1,50,150,50
leg = 2
make mesh from object leg,1
delete object 1
make object box 1,6,8,6
color object 1,rgb(255,0,0)
PERFORM CHECKLIST FOR OBJECT LIMBS 1
totalLimbs = checklist quantity()
add limb 1,totalLimbs,head
color limb 1,totalLimbs,rgb(255,128,0)
OFFSET LIMB 1, TotalLimbs, 0.0,5.0, 0.0
inc totalLimbs,1
add limb 1,totalLimbs,leg
OFFSET LIMB 1, TotalLimbs, -1.5,-6.0, 0.0
inc totalLimbs,1
add limb 1,totalLimbs,leg
OFFSET LIMB 1, TotalLimbs, 1.5,-6.0, 0.0
inc totalLimbs,1
add limb 1,totalLimbs,leg
rotate limb 1,totalLimbs,0.0,0.0,90.0
OFFSET LIMB 1, TotalLimbs, -6.0,2.0, 0.0
inc totalLimbs,1
add limb 1,totalLimbs,leg
rotate limb 1,totalLimbs,0.0,0.0,90.0
OFFSET LIMB 1, TotalLimbs, 6.0,2.0, 0.0
` make ball to throw at the man to check collision
make object sphere 9,4
color object 9,rgb(0,0,250)
null = make vector3(1)
move camera - 50
x# = object position x(1)
y# = object position y(1)
z# = object position z(1)
position camera x#,y# + 50,z#
move camera - 150
GetRndBallLoc(x#,y#,z#)
repeat
MoveBall()
sync
until spacekey() = 1
end
function getchardistance(ob1,ob2)
set vector3 1,object position x(ob1)-object position x(ob2),object position y(ob1)-object position y(ob2),object position z(ob1)-object position z(ob2)
dist# = length vector3(1)
endfunction dist#
function GetRndBallLoc(x#,y#,z#)
xadd# = rnd(30) + 30
yadd# = rnd(10)
zadd# = rnd(30) + 30
if rnd(100) > 50 then xadd# = xadd# * -1
if rnd(100) > 50 then yadd# = yadd# * -1
if rnd(100) > 50 then zadd# = zadd# * -1
cx# = x# + xadd#
cy# = y# + yadd#
cz# = z# + zadd#
position object 9,cx#,cy#,cz#
t# = rnd(5)
if rnd(100) > 50 then t# = t# * -1
point object 9,x#,(y# + t#),z#
endfunction
function MoveBall()
move object 9,speed#
` find out if we have a collision
getchardistance(1,9)
if dist# < object size(1)
text 10,10,"got it!!!" : sync : wait 150
CheckLimbs() : ` see which limb is the closest
endif
endfunction
function CheckLimbs()
lowest# = 1000.0 : winner = 0
cx# = object position x(9)
cy# = object position y(9)
cz# = object position z(9)
for i = 1 to (TotalLimbs - 1)
x# = limb position x(1,i)
y# = limb position y(1,i)
z# = limb position z(1,i)
set vector3 1,cx# - x#,cy# - y#,cz# - z#
dist# = length vector3(1)
if dist# < lowest# then lowest# = dist# : ClosestLimb = i
next i
if ClosestLimb > 0
text 10,10,"limb #" + str$(ClosestLimb) + " is the closest!"
sync
wait 1500
GetRndBallLoc(object position x(1),object position y(1),object position z(1))
endif
endfunction
LB