Intersect Range (Raw Collision)
Blitz3D Forums/Blitz3D Programming/Intersect Range (Raw Collision)
| ||
Is there a way to do a linepick but instead of returning the entity of collision to return the range down the line at which collision occured. IE: vectorLength#=rangePick(EntityNo,srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#) Help please, I am struggling to master the supplied collision system! :) |
| ||
PickedTime() does that, more or less. After a successful pick multiply the length of your pick vector by it: pickrange#=pickedtime()*sqr(lenx*lenx+leny*leny+lenz*lenz). Ignore the docs on pickedtime(), they are barking. Not sure exactly what you want that rangepick function to do though. |
| ||
Untested, but should work.Function RangePick(srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#,radius#) LinePick(srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#,radius#) If PickedEntity()<>0 xd#=PickedX#()-srcX# yd#=PickedY#()-srcY# zd#=PickedZ#()-srcZ# Return Sqr(xd*xd + yd*yd + zd*zd) End If End Function |
| ||
You can do a linepick and get the picked x, y, and z positions (along with the normal of the picked object), from which you can work out essentially the same thing. so it would actually be something like, rangePick(EntityNo,srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#) vectorLength#=3ddistance(srcx#,srcy#,srcz#,pickedx(),pickedy(),pickedz()) obviously you need a 3d distance function but I'm sure you can work that one out :) |
| ||
Tbank you, I modified your function to return a float and it works perfectly ! (after realising it doesnt pick backfaces that is :) ). Cheers |
| ||
Oops, yeah, forgot to make it return a float. Glad you have it working anyway. |