Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / 3D Monster Hunt Tutorial - Sec 3.4 Shooting Bullets - Baffles me. Please explain this code to me

Author
Message
HuHa
22
Years of Service
User Offline
Joined: 27th Apr 2004
Location:
Posted: 20th Nov 2004 23:49
I have been going thru the Monster Hunt 3D tutorial and have had no problems in understanding it untill I reached sec 3.4 Shooting Bullets.

The 2 below listed pieces of code have me baffled. What I cannot understand is as to how does the bullet look like it is being shot thru the barell of the gun (cylinder object).

This does not seem logically possible but yet we get the precise effect of the bullet leaving the barell of the gun.

The first piece of code positons the gun object at coordinates 0, -7 and 15.

In the second piece of code listed here the bullet is being positioned at the same location as the camera and the camera can be basically moved about anywhere in the 3D world.

If the camera were moved to a location of X:5000 Y:5000 Z:5000 and the bullet fired it would still give the effect that the bullet were being shot thru the barrel of the gun when the locations of the gun and the bullet are totally different.

How does this happen. It does not seem logical thought the effect is great.

I know that the Lock Object on 1 command locks the cylinder barrel object into the 3D world such that camera movement does not effect it. I do not understand if this Lockin could have something to do with having the bullet fire thru the cylinder object locked into the 3D world even when the camera and thus the bullet could be located at any random 3D point.

Listed below are the 2 pieces of code which baffle me:
*******
rem Make Gun
Make Object Cylinder 1, 2
XRoatate Object 1, 90
Fix Object Pivot 1
Scale Object 1, 100,100, 500
Postion Object 1, 0, -7, 15
Lock Object On 1
*********
Receive input from Mouse button and shoot bullet
Object 2 below represents the bullet
X#, Y#, Z# represent the camera position
If Mouseclick() = 1 and Bulletlife = 0
Position Object 2, X#,Y#+43, Z#
Set object to camera orientation 2
Bulletlife = 25
Show object 2
Endif
Chris K
22
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 21st Nov 2004 00:25
The lock object command automatically moves and rotates the object as if it were joined to the camera.
HuHa
22
Years of Service
User Offline
Joined: 27th Apr 2004
Location:
Posted: 21st Nov 2004 23:17
Thanks for clearing my query.

Login to post a reply

Server time is: 2026-07-17 14:45:03
Your offset time is: 2026-07-17 14:45:03