Quote: " Or could i just keep stretching the cylinder further till it hits a wall?"
thats the method
but i would suggest keep checking for hit by with function like that:
//to use the function, is something like that:
Coll = CheckForCollisionOfWall(Object Posisiton x(GunObj),object position y(GunObj),object position z(GunObj),Camera angle x(),camera angle y(),400)
//now, if collision return 1, we will paste the cylinder:
if Coll = 1
Dist# = MyDistanceFormula(PX,PY,PZ,Object Posisiton x(GunObj),object position y(GunObj),object position z(GunObj))
create object cylinder 100,1
scale object 100,100,100*Dist,100
point object 100,PX,PY,PZ
endif
//since functions cant pass multiply vars, i use GLOBAL this PX, PY, PZ as the calculated XYZ area of the wall.
global PX as Float
global PY as Float
global PZ as Float
//SX, SY, SZ is your gun positions (where the beam shoots)
//RX, RY is your player rotation (so the function will know from what angle it needs to "shoot" collision check
//LaserPossibleDistance is maximum distance you want to shoot the laser
function CheckForCollisionOfWall(SX as Float, SY as Float, SZ as Float, RY as FLOAT, RX as Float,LaserPossibleDistance as Integer)
//creating small box to check for hit:
make object cube 1000,1
hide object 1000
{
setup here your sparky collision on the cube we just made
i dotn rememebr the correct way, sorry.
}
//positioning and pointing the object same as player/camera.
position object 1000,SX,SY,SZ
rotate object RX,RY,object angle z(1000)
//this is check for hit:
for a = 1 to LaserPossibleDistance step 5
//this is where you using the sparky collision
//Old Object Position
PX = Object position x(1000)
PY = Object position y(1000)
PZ = object position z(1000)
//we saved the XYZ positions as buffer
//now, move the the box lil bit forward:
move object 1000,a
//now, check back the possible collision in sparky by puting the old PX,PY,PZ to sparky check, and reciving new once:
//as i said, i dont remember the sparky commands, but its something like:
Collide = Spary CollisionCheck(1000,PX,PY,PZ,object position x(1000),object position y(1000),object position z(1000),10)
//now if collision exists with the wall, the Collide shoulnt return 0:
if Collide <> 2
PX = Get Sparky Collision X(1000)
PY = Get Sparky Collision Y(1000)
PZ = Get Sparky Collision Z(1000)
exitfunction 1
endif
next a
delete object 1000
endfunction 0
this code doesnt compliles.
just try to understand what im doing here.
its pretty easy once you understand what i did.