OK so I have taken out my commands (Well remmed them) that created the original collision, now I need to know what the command to make the camera collide with the world is, I know I have to call all those things and I could probably find out how to do it alone but it would take me a lot of time and energy (really i'm just pretty lazy) Here is my code, could someone please explain to me (Again I am sorry) The routine for calling constabts and collisions and how I would be able to put thet in
this code. What I really need to know is.
(A)what the command for the camera2world collision
(B)The order in which I would call the constants
@Lost In Though, I know I am a bad student here in the whole NGC thing but could you please give it another try
I will listen to all your advice,
By the way here is the code (Without Collisions)
`***************************
`.X Model sliding collision
`By Kensupen and Lokidecat
`Nerdsoft Creations (C) 2003
`***************************
`This uses all native DBPro commands to give a user sliding collision
`against ANY .X model to slide on ANY angle. It works almost as good as BSP
`collision, except for height. If you can walk onto an object, it just
`puts you at that height. I might try to advance the code later to give
`a smooth height adjustment.
rem load music "song.mp3",1
rem play music 1
rem loop music 1
autocam off
set image colorkey 255,0,255
sync on
srate=60
sync rate srate
color backdrop 0
set camera range 1,5000
set ambient light 75
`Our cheap level
load object "C:\Documents and Settings\User\Desktop\data\prison8.x",1
set object transparency 1,2
dir$=get dir$()
`Height cam is off the ground
charht#=50
dharht#=40
`speed to move
spd#=10
`set the radius for collisions
rem radius#=10.0
`set initial camera position
fog on
position camera 0,charht#,0
yrotate camera 180
`number of checks
`the lower this number is, the more off the collisions will be vs. any rotated object.
`also, the lower the number, the more speed it runs at.
`lowest for rotated collision is 4(non rotated/box collision) max is 360, but 360 is WAAAY slow
`I'd advide is you play with this number to keep with a multiple of 4
remstart
checks=8
if checks<4 then checks=4
if checks>360 then checks=360
`width of the angles
angwidth=360/checks
`make arrays for collision data
dim ang#(checks-1,2)
dim sort#(checks-1,2)
rem if keystate(17) then
rem _light:
rem if mouseclick()=1 then gosub _light2
rem _light2:
rem make light 1234124
rem set point light 1234124,0,0,0
rem set light range 1234124,2000
rem make object sphere 2+l,50 : ghost object on 2+l
rem if l>1 then hide light 1234124 : hide object 2+l
remend
do
rem load animation "knifekill2.AVI",1
rem play animation 1
rem loop animation 1
rem text 10, 10, "ScanCode of pressed key: " + str$(scancode())
text 10, 10, "Health:100"
text 10,20, "Armor:100"
rem text 10, 30, "ASCII Code: " + str$(asc(inkey$()))
sync
set cursor 0,0
rem print "Sync Rate set at ",srate," Press Enter to change"
rem print "FPS:",screen fps()
if scancode()=0 then hold=0
if returnkey()=1 and hold=0
hold=1
if srate=60
srate=0
else
srate=60
endif
sync rate srate
endif
`Get initial positions and a revert set
oldx#=camera position x()
oldz#=camera position z()
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
ca#=camera angle y()
`generic mouselook
mx#=mousemovex()/4.0
my#=mousemovey()/4.0
rem if mouseclick()=0 then show mouse
rem if mouseclick()>0
hide mouse
position mouse 320,240
xrotate camera wrapvalue(camera angle x()+my#)
yrotate camera wrapvalue(camera angle y()+mx#)
if camera angle x()>80 and camera angle x()<180 then xrotate camera 80
if camera angle x()<270 and camera angle x()>180 then xrotate camera 270
rem endif
if scancode()=17
cx#=newxvalue(cx#,ca#,spd#)
cz#=newzvalue(cz#,ca#,spd#)
position camera cx#,cy#,cz#
endif
`If you want to back up
if inkey$()="s"
cx#=newxvalue(cx#,wrapvalue(ca#-180),spd#)
cz#=newzvalue(cz#,wrapvalue(ca#-180),spd#)
position camera cx#,cy#,cz#
endif
if inkey$()="a"
cx#=newxvalue(cx#,wrapvalue(ca#-90),spd#)
cz#=newzvalue(cz#,wrapvalue(ca#-90),spd#)
position camera cx#,cy#,cz#
endif
if inkey$()="d"
cx#=newxvalue(cx#,wrapvalue(ca#+90),spd#)
cz#=newzvalue(cz#,wrapvalue(ca#+90),spd#)
position camera cx#,cy#,cz#
endif
`Show the camera angle
rem print "Camera angle:",camera angle y()
`The main sliding collision code
rem gosub _collision
`My code to walk up a ramp if the angle isn't too steep
rem gosub _ramp
rem gosub _light
`A just in case reset
if spacekey()=1 then position camera 0,200,0
sync
loop
remstart
_ramp:
`get positions again
cx#=camera position x()
cz#=camera position z()
`Get your old height
oldht#=camera position y()
`calc new height using intersect object from the old height down charht# units
sub#=intersect object(1,cx#,oldht#,cz#,cx#,oldht#-(charht#*2),cz#)
ht#=(oldht#+charht#)-sub#
if sub#=0 then ht#=charht#
`do some gravity
grav#=grav#-0.25
`if you are going up a ramp
if oldht#+grav#<ht#
grav#=0.0
position camera cx#,ht#,cz#
else
`if you are falling
ht#=oldht#+grav#
position camera cx#,ht#,cz#
endif
return
_collision:
`make 72 collision points. You can use more or less, but this number seems to work good.
`These are vectors every 5 degrees from the camera position out.
`They return the distance when they hit an object
for x=0 to checks-1
chx#=newxvalue(cx#,x*angwidth,100)
chz#=newzvalue(cz#,x*angwidth,100)
ang#(x,1)=intersect object(1,cx#,cy#,cz#,chx#,cy#,chz#)
if ang#(x,1)=0 then ang#(x,1)=999999
ang#(x,2)=x*angwidth
sort#(x,1)=ang#(x,1)
sort#(x,2)=ang#(x,2)
next x
`sort the array to find the closest object and it's degrees
for x=0 to checks-2
for y=x+1 to checks-1
if ang#(x,1)>ang#(y,1)
temp#=ang#(x,1)
temp2#=ang#(x,2)
ang#(x,1)=ang#(y,1)
ang#(x,2)=ang#(y,2)
ang#(y,1)=temp#
ang#(y,2)=temp2#
endif
next x
next y
`This is the closest wall and what degrees you would face to see it
rem print "Angle to closest wall:",ang#(0,2)
rem print "Distance to that wall:",ang#(0,1)
`find +-90 degrees from the closest one for when you walk into a corner so it doesn't shake
prev=wrapvalue(ang#(0,2)-90)/angwidth
nxt=wrapvalue(ang#(0,2)+90)/angwidth
newd#=radius#-ang#(0,1)
newa#=wrapvalue(ang#(0,2)-180)
newd1#=radius#-sort#(prev,1)
newa1#=wrapvalue(sort#(prev,2)-180)
newd2#=radius#-sort#(nxt,1)
newa2#=wrapvalue(sort#(nxt,2)-180)
`if you are less than radius from a wall, push you out to 20 from it
if ang#(0,1)<radius# and ang#(0,1)>0.0
repx#=newxvalue(cx#,newa#,newd#)
repz#=newzvalue(cz#,newa#,newd#)
position camera repx#,cy#,repz#
endif
cx#=camera position x()
cz#=camera position z()
`this is if you are coming into a corner, this pushes you sideways
if sort#(prev,1)<radius# and sort#(prev,1)>0.0
repx1#=newxvalue(cx#,newa1#,newd1#)
repz1#=newzvalue(cz#,newa1#,newd1#)
position camera repx1#,cy#,repz1#
endif
cx#=camera position x()
cz#=camera position z()
`and the other way. above is left, this is right
if sort#(nxt,1)<radius# and sort#(nxt,1)>0.0
repx2#=newxvalue(cx#,newa2#,newd2#)
repz2#=newzvalue(cz#,newa2#,newd2#)
position camera repx2#,cy#,repz2#
endif
return