how is collision with cones supposed to work. When i try using the normal object collision command, it only works if I am in a certain spot that isn't even in the cone. I am very confused. I am using DBC. Here is my code.
`object number key
`1-200=enemies
`201-400=enemies sight
`401-600=enemies hearing
`601-800=non-moving objects
`801-1000=moving objects
`1001-3000=bullets
`3001-4000=special collisions and boundaries
`4001-herosound
`4002-enemy limb attachment
`65535=hero
`65530-65534=landscape
`65500-65529=sky(moon,stars, etc)
`65498-65499=camera
rem loads the falling sound
load 3dsound "thump.wav",1
dim vertvel(65535)
dim height(65535)
dim spothit(65535)
sync on
rem makes and sets up the landscape
make object plain 65530,400,400
make object plain 65531,40000,40000
xrotate object 65530,90
color object 65530,rgb(255,0,0)
xrotate object 65531,90
color object 65531,rgb(0,255,0)
position object 65531,object position x(65531),object position y(65531)-100,object position z(65531)+400
rem loads/creates and positions hero
make object box 65535,50,75,50
`color object 65535,0
position object 65535,object position x(65535),object position y(65535)+150,object position z(65535)
autocam off
rem makes camera positioning object and limb
make object sphere 65499,1
position object 65499,object position x(65535),object position y(65535),object position z(65535)
make mesh from object 1,65499
delete object 65499
add limb 65535,1,1
offset limb 65535,1,0,75,-150
hide limb 65535,1
make object sphere 65498,1
position object 65498,object position x(65535),object position y(65535),object position z(65535)
make mesh from object 2,65498
delete object 65498
add limb 65535,2,2
hide limb 65535,2
link limb 65535,1,2
rem positions the camera at the limbs position and points the camera at the
rem hero's x & z coords and at the limbs y coord.
position camera limb position x(65535,1),limb position y(65535,1),limb position z(65535,1)
point camera object position x(65535),object position y(65535),object position z(65535)
rem sets up camera distance variables
x4=0
y4=100
z4=150
rem makes enemies and their eyesight/hearing
rem enemy one
make object box 1,50,75,50
ghost object on 1
make object sphere 4002,1
make mesh from object 1,4002
add limb 1,1,1
delete object 4002
rem make enemy one sight
make object cone 201,50
scale object 201,200,300,200
pitch object up 201,90
ghost object on 201
position object 1,object position x(1),object position y(1),object position z(1)
glue object to limb 201,1,1
position object 201,0,25,100
set object collision off 201
`hide object 201
rem make enemy one hearing
make object sphere 401,300
set object 401,1,1,0
ghost object on 401
glue object to limb 401,1,1
set object collision off 401
`hide object 401
move object 1,600
turn object right 1,180
rem main loop
do
gosub camvars
gosub keycontrol
text 0,0,str$(turny)
enemycollision=object collision(65535,0)
if enemycollision>=1 AND enemycollision<600
move object 65535,-1
if object collision(65535,enemycollision)=1
move object 65535,2
endif
endif
for i=1 to 65535
if object exist(i) and i<>65530 and i<>65531 and i<200 or object exist(i) and i<>65530 and i<>65531 and i>600
object=i
gosub gravity
gosub soundandfall
endif
next i
`text 50,0,str$(vertvel(object))
if mousemovex()<>0
`if mousex<>mousex()
`1=left
`2=right
if mouse_x<mousex() then move=1
if mouse_x>mousex() then move=2
gosub circlecam
endif
for i=1 to 3
gosub camvars
gosub cammove
next i
position camera camera position x(),limb position y(65535,1),camera position z()
`set object collision on 201
`unglue object 201
`if object collision(201,65535)=1
` gosub hero_sighted
`else
` color object 201,rgb(255,255,255)
`endif
`set object collision off 201
`glue object to limb 201,1,1
for i=1 to 200
if object exist(i)
enemy=i
gosub enemyai
endif
next i
sync
mouse_x=mousex()
loop
end
camvars:
x1=camera position x()
x2=object position x(65535)
x3=x2-x1
z1=camera position z()
z2=object position z(65535)
z3=z2-z1
y1=camera position y()
y2=object position y(65535)
y3=y2-y1
xd=camera position x()-object position x(65535)
zd=camera position z()-object position z(65535)
distance=sqrt((xd*xd)+(zd*zd))
return
keycontrol:
`point camera object position x(65535),object position y(65535),object position z(65535)
limby=limb angle y(65535,1)
if upkey()=1
move object 65535,5
` move camera 1.2
endif
if downkey()=1
move object 65535,-5
` if z4=z3
` move camera
` move camera -1
endif
if rightkey()=1
turn object right 65535,1
` limby=limb angle y(65535,2)+1
` if limby>360 then limby=limby-360
` if limby<=0 then limby=limby+360
` rotate limb 65535,2,0,limby,0
endif
if leftkey()=1
turn object left 65535,1
` limby=limb angle y(65535,2)-771
` if limby>360 then limby=limby-360
` if limby<=0 then limby=limby+360
` rotate limb 65535,2,0,limby,0
endif
if spacekey()=1
gosub jump
endif
` if upkey()=1 then move camera 1
` if downkey()=1 then move camera -1
` if rightkey()=1 then turn camera right 1
return
gravity:
collision=object collision(object,0)
`65530 and 65531(down)
if collision=0
spothit(object)=0
vertvel(object)=vertvel(object)-1
height(object)=height(object)+1
else
if collision<>65535
repeat
position object object,object position x(object),object position y(object)+.1,object position z(object)
until object collision(object,0)=0
endif
if object collision(65535,0)<>0
jump=0
endif
position object object,object position x(object),object position y(object)-.1,object position z(object)
vertvel(object)=0
` position object 65535,object position x(65535),object position y(65535)+1,object position z(65535)
endif
return
soundandfall:
position object object,object position x(object),object position y(object)+vertvel(object),object position z(object)
if object collision(object,0)<>0 and spothit(object)=0
`play sound 1
spothit(object)=1
make object sphere 4001,height(object)*10
`hide object 4001
ghost object on 4001
position object 4001,object position x(object),object position y(object),object position z(object)
play sound 1
position sound 1,object position x(object),object position y(object),object position z(object)
if height(object)>100
height(object)=100
endif
set sound volume 1,height(object)
set object 4001,1,1,1
set object object,1,1,0
ghost object on object
`wait key
delete object 4001
endif
return
circlecam:
`turny=turny+mousemovex()
turny=limb angle y(65535,2)+mousemovex()
if turny>360 then turny=turny-360
if turny<=0 then turny=turny+360
rotate limb 65535,2,0,turny,0
position camera limb position x(65535,1),limb position y(65535,1),limb position z(65535,1)
` point camera object position x(65535),object position y(65535)-50,object position z(65535)
return
cammove:
` if distance>150
` camx=camera angle x()
` camy=camera angle y()
` camz=camera angle z()
point camera object position x(65535),object position y(65535)-50,object position z(65535)
move camera distance-150
` endif
` if distance<150
` move camera distance-150
` endif
if y4<y3
` move camera y3-y4
position camera camera position x(),camera position y()+y3,camera position z()
endif
if y4>y3
` move camera y3-y4
position camera camera position x(),camera position y()+y3,camera position z()
endif
`xrotate camera camx
`yrotate camera camy
` zrotate camera camz
return
jump:
if jump=0
jump=1
vertvel(65535)=20
repeat
position object 65535,object position x(65535),object position y(65535)+1,object position z(65535)
until object collision(65535,0)=0
endif
return
enemyai:
if rotater=180 and mover=180
rotater=0
mover=0
endif
if mover<180 and rotater=0
move object enemy,1
mover=mover+1
endif
if rotater<180 and mover=180
turn object right enemy,1
rotater=rotater+1
endif
set object collision on 201
`unglue object 201
if object collision(201,65535)=1
gosub hero_sighted
else
color object 201,rgb(255,255,255)
endif
set object collision off 201
`glue object to limb 201,1,1
return
hero_sighted:
show object 201
`wait key
color object 201,rgb(255,0,0)
return
also, if you see something in the code that is either a hindrance to the game or is bad for other reasons, tell me!