the following lines will make it follow the camera at a fixed position (no walk wobble or anything like that)
position object objnum,camera position x(),camera position y(),camera position z()
set object to camera orientation objnum
will get the gun object (objnum) faceing the same way and angle as the camera and position it wherever the camera is, the trouble is its right in the middle of the screen and not far enough forwards to see properly(inside the camera cull range), so do..
pitch object down objnum,45
move object objnum,3
the first will point the gun downwards 45 degrees and the second will move it forwards and down a distance of 3, the exact distance and angle is up to where you want the gun to appear exactly, at the moment it will now be visible in front of you and turn with the camera etc, but its pointing downwards 45deg (or whatever), so do
pitch object up objnum,45
sync
this will ensure the gun is level again, then just do that sequence of commands every loop, it might look slow but actualy positioning objects is very fast, the system can do the math internaly at least as fast as you could do it in code, heres an example where a cube takes the place of the gun, note that the angles and distance where modified for this code, once you have the position you can add a bit of code to make it wave about when you walk, but this is ok for a start.
sync on: sync rate 40
for i=2 to 200
make object sphere i,rnd(3)+1
position object i,rnd(100)-50,0,rnd(100)-50
color object i,rgb(rnd(255),rnd(255),rnd(255))
next i
make object cube 1,1
disable object zdepth 1
do
control camera using arrowkeys 0,0.1,1
position object 1,camera position x(),0,camera position z()
set object to camera orientation 1
pitch object down 1,20
move object 1,2
pitch object up 1,20
sync
loop
also notice that I disabled the objects zdepth in this code, try remming the line out and see what happens to the gun when you approach spheres, I don`t mention lock object on (glues an object to a fixed position on the screen, almost the same as this code does), because it`s no use if you want to add walk motion or aiming dither, two things that make a FPS look better, this gives a fixed position but you can add in motion to its position to make it wave around the average or move from side to side etc.
Dr Frankenstiens mum told him to make some new friends, not knowing where this was going to lead.