
You can design a sophisticated gun for your game but in our tutorial, our gun is only two parts of a red cylinder - the sight of a bazooka? - and the bullet is a little red sphere.

We create this objects as part of the 3ds max world and they can be placed in any local.
Using the program, we need to put they in front of the eyes of the avatar.
We know how to do this! In the 3dD Basic Kit we put the camera glued to the avatar. Is the samething.
The cameraobj script will be (new lines bolded):
property mycam
property aux --
property cameraoffset -- ration of how far up and behind the followmodel
property gun
property gunoffset
global avatarobj,myworld
on new me
aux = myworld.newmodel("aux")
mycam = myworld.camera[1]
aux.visibility = #none
mycam.projectionangle = 95
cameraoffset = [0.001,-0.002]
gunoffset=[-10,80]
gun=myworld.model("gun")
return me
end
on control me
aux.transform.interpolateto(myworld.model("avatar").getworldtransform(), 100.0)
camvect = (avatarobj.upvect*cameraoffset[1]+ avatarobj.fwvect*cameraoffset[2])
aux.translate(camvect, #world)
aux.pointat(myworld.model("avatar").worldposition )
lag = 100
mycam.transform.interpolateto(aux.getworldtransform(), lag)
gun.transform.interpolateto(myworld.model("avatar").getworldtransform(), 100.0)
gunvect = (avatarobj.upvect*gunoffset[1]+ avatarobj.fwvect*gunoffset[2])
gun.translate(gunvect, #world)
gun.pointat(myworld.model("avatar").worldposition)
end
In the next lesson we will see how to shoot the bullet and to test the collision against the target.
Play the demo. It is complete. You need to destroy the plaque with the logo. To shoot press the space bar.To shoot again you need to recharge the bazooka pressing the r key!!!! You only can do this after the beep!!!! The demo has sound! Walk as usual, using the arrow keys.
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
