Subject: collision question 2004-03-30 - By welchc@(protected)
Back
I've been trying to tackle this issue also. I am trying to avoid using the built in collision code because its slow as hell. I've found that casting a ray is much faster, bet I'm still having some issues. Here's some code I came up will that kinda works. I would like to compress it though. Its seems redundant. Also, sometimes it works and sometimes it doesn't. Help anyone?
On checkforCollision
--Boundry Management boundaryWall = scene.model("walkabout_areaShape")
targetpos = scene.model("target").getworldtransform().position
if keypressed(123) then -- 123 = left arrow key
modelsListN = scene.modelsunderray(vector(-3, targetpos.Y, targetpos.Z ), vector(1.0001,0.0001,0.0001), #detailed) whichmodel = void totalmodels = modelsListN.count repeat with x = 1 to totalmodels if modelsListN[x].model = scene.model("walkabout_areaShape") then put modelsListN[x].model.name && "hit" else put "left" pCharacter.translate(TheSpeed,0,0) end if end repeat end if
if keypressed(124) then -- 124 = right arrow key
modelsListS = scene.modelsunderray(vector(3, targetpos.Y, targetpos.Z), vector(-1.0001,0.0001,0.0001), #detailed) whichmodel = void totalmodels = modelsListS.count repeat with x = 1 to totalmodels if modelsListS[x].model = boundaryWall then put modelsListS[x].model.name && "hit" else put "right" pCharacter.translate(-TheSpeed,0,0) end if end repeat end if
if keypressed(125) then -- 125 = down arrow key
modelsListE = scene.modelsunderray(vector(targetpos.X, -3, targetpos.Z ), vector(0.0001,1.0001,0.0001), #detailed) whichmodel = void totalmodels = modelsListE.count repeat with x = 1 to totalmodels if modelsListE[x].model = boundaryWall then put modelsListE[x].model.name && "hit" else put "down" pCharacter.translate(0,TheSpeed,0) end if end repeat end if
if keypressed(126) then-- 126 = up arrow key
modelsListW = scene.modelsunderray(vector(targetpos.X, 3, targetpos.Z), vector(0.0001,-1.0001,0.0001), #detailed) whichmodel = void totalmodels = modelsListW.count repeat with x = 1 to totalmodels if modelsListW[x].model = boundaryWall then put modelsListW[x].model.name && "hit" else put "up" pCharacter.translate(0,-TheSpeed,0) end if end repeat end if
modelsListN = void modelsListS = void modelsListE = void modelsListW = void
end
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
|
|