Character Controller and Ray Casting bug
Ray casting seems to detect a collision with a character controller (usually), but in this example always seems to return 0 as the object collided with. Normally the
phy get ray cast object() command works fine, but not with character controllers.
Leave the mode as 0 to see the character controller hit the rigid body (to prove collision), then set it to 1 to perform a raycast instead. It detects it, but returns 0.
`***************************************
`Change mode to 0 for standard collision
`Change mode to 1 for ray casting test
`***************************************
mode = 0
set display mode 1024,768,32,0
sync on: sync rate 60
autocam off
position camera 100,50,50
phy start
make object box 1,10,50,10
phy make capsule character controller 1, 0, 50, 0, 5, 50, 1, 10,10
make object box 2,100,10,100
`position object 2,0,0,0
phy make rigid body static box 2
make object box 3,1,1,100
color object 3,rgb(255,0,0)
position object 3,0,25,25
yrotate object 3,90
if mode=0 then phy make rigid body static box 3
do
point camera object position x(1),object position y(1),object position z(1)
phy move character controller 1,5
if mode = 1
temp = phy ray cast all shapes(object position x(3)-100,object position y(3),object position z(3),1,0,0)
if phy get ray cast hit()
do
text 1,1,"OBJECT HIT WITH ID OF: " + str$(phy get ray cast object())
sync
loop
endif
endif
phy update
sync
loop
I'm wondering whether raycasts to character controllers might be buggy in general. I've been trying to ray cast into my character controllers for ages in my game, but can't hit any of the bloody things.
I keep casting rays straight through them and hitting the level behind.
Edit: Btw, here's a confusing bit of command instructions that might've confused DBKing above. When making a character controller the help reads:
Quote: "
ID - identification number of the character controller, these ID numbers are unique to character controllers"
But that's not true, because the ID has to be an object that you've made for the character controller to bind to. So they basically function the same way as other rigid bodies in terms of their ID.
MIKE EDIT - fixed