Hmmm, strange. I suppose the camera vector command doesn't work as I would've assumed. Here's a cheating way that'll work for you.
`Give bullet force in direction of camera
oldx# = camera position x()
oldy# = camera position y()
oldz# = camera position z()
move camera 1
set vector3 1,camera position x()-oldx#,camera position y()-oldy#,camera position z()-oldz#
normalize vector3 1,1
move camera -1
force# = 1000
phy add rigid body force obj,x vector3(1)*force#,y vector3(1)*force#,z vector3(1)*force#,3
Here's my silly box shooter I setup to test it:
set display mode 1024,768,32
sync on: sync rate 60
autocam off
temp = make vector3(1)
phy start
phy update 0
position camera 0,50,-500
make object plain 1,100,1000
xrotate object 1,270
color object 1,rgb(255,0,0)
phy make rigid body static box 1
`Make some targets
for x=1 to 10
for z= 1 to 10
obj = GetNextFreeObj()
height# = 10+rnd(10)
make object box obj,4+rnd(5),height#,1+rnd(2)
position object obj,(x-5.5)*10,height#/2.0,(z-5)*100
phy make rigid body dynamic box obj
phy set rigid body mass obj,100
next z
next x
do
phy update 1
`If ready to fire again
if reload = 0
`If fire is clicked
if mouseclick() = 1
`Set reload time back to 30
reload = 10
`Make bullet
obj = GetNextFreeObj()
make object sphere obj,2
color object obj,rgb(0,0,255)
position object obj,0,45,-500
phy make rigid body dynamic sphere obj
phy set rigid body mass obj,10
`Give bullet force in direction of camera
oldx# = camera position x()
oldy# = camera position y()
oldz# = camera position z()
move camera 1
set vector3 1,camera position x()-oldx#,camera position y()-oldy#,camera position z()-oldz#
normalize vector3 1,1
move camera -1
force# = 1000
phy add rigid body force obj,x vector3(1)*force#,y vector3(1)*force#,z vector3(1)*force#,3
endif
else
dec reload,1
endif
`Mouse look camera
yrotate camera wrapvalue(camera angle y()+mousemovex())
xrotate camera wrapvalue(camera angle x()+mousemovey())
phy update 0
sync
loop
function GetNextFreeObj()
obj = 1
while object exist(obj) = 1
inc obj,1
endwhile
endfunction obj