Edited : Works
however i used SphereCast with a radius instead of raycast (doesn't change anything with
RAYcast when i change collision modes or when i move objects away .. Raycasting stay on the first hit !! very strange.. maybe raycast use frontbuffer instead of the backbuffer ... i dont know)...
Snippet :
// UDT
Type CollisionPoint
ObjectID
X#
Y#
Z#
EndType
// Global Collision Variable Receiver
Global dim CollisionsPoints[100] as CollisionPoint // Take care of the array about the max Collision Count :p)
function MultipleObjectRayCast(X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#)
CollisionCount=0
repeat
ObjectHit=ObjectSphereCast( 0, X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#)
if ObjectHit>0
inc CollisionCount,1
CollisionsPoints[CollisionCount].ObjectID=ObjectHit
CollisionsPoints[CollisionCount].X#=GetObjectRayCastX(0)
CollisionsPoints[CollisionCount].Y#=GetObjectRayCastY(0)
CollisionsPoints[CollisionCount].Z#=GetObjectRayCastZ(0)
SetObjectCollisionMode(ObjectHit,0)
endif
until ObjectHit=0
for i=1 to CollisionCount
SetObjectCollisionMode(CollisionsPoints[i].ObjectID,1)
next
endfunction CollisionCount
////////////// Usage
// Example to show all ObjectIDs along the ray from Camera to object ObjID :
TotalHits=MultipleObjectRayCast( GetCameraX(1), GetCameraY(1), GetCameraZ(1), GetObjectX(ObjID), GetObjectY(ObjID), GetObjectZ(ObjID))
if (TotalHits>0)
for i=1 to TotalHits
print ("Collision "+str(i)+" : "+str(CollisionsPoints[i].ObjectID))
next
endif