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.

Dark GDK / 3d flight simulator shooting problems

Author
Message
Shadow Wolf
16
Years of Service
User Offline
Joined: 6th Jul 2008
Location:
Posted: 12th Jul 2008 04:09
I made a 3d flight simulator where my plane can fly around using the mouse but I now want to add a shooting system where there is an aiming display in front of the plane and when you click the left mouse button it shoots in the direction of the aiming display. Any ideas on how to do this? Code would be really helpful!!
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 18th Jul 2008 16:58
well... you can add a plain object as the aiming display and then link it to the plain object, then when you shoot ,you take the angle between the XYZ of the plane and the XYZ of the aim display.
And there you go
Shadow Wolf
16
Years of Service
User Offline
Joined: 6th Jul 2008
Location:
Posted: 20th Jul 2008 22:57
I have a a crosshair sprite in the center of the screen so would I be able to have the plane shoot towards the crosshair sprite.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 21st Jul 2008 06:05 Edited at: 21st Jul 2008 09:59
Quote: "so would I be able to have the plane shoot towards the crosshair sprite."


You may want to reconsider how things should be done.

You have a camera view.
It looks in a particular direction and the center of the screen is the center view of the camera.

You have gun/guns.
They are positioned in free space at a certain offset to the camera (certain offset in the X direction, Y direction, Z direction, Elevation/declination offset, compass bearing offset)
Use these offsets to get the actual 3D space X,Y,Z, compass direction, Elevation/declanation, of the individual guns.

Start you bullets in free space at these gun positions.

If you want to make it realistic, then as the bullets move, make sure gravity starts to accelerate the bullets in a downwards direction, and air resistance starts to slow the bullets down.

NOW position the crosshair on your screen so that the crosshair intersects the bullet stream at the effective target distance that the pilot should be shooting from (WW2 aircraft usually about 200 meters).

Hope that gives you something to think about.

Remember: Guns never shoot towards the crosshair. It is the crosshair that always shows where the guns are shooting.

EDIT:
Here you can see an example where Gun convergence has been applied and gravity effects apply to the bullets.
The bullet stream falls away from the targeted area (crosshairs) before the bullets even reach the desired target distance.
The targeting graticule would now have to be dropped a bit, or the guns tilted upwards a bit.


The art of doing a good game is in the planning and not in the code writing.
Get your game structure correct first before you even write one line of code. (the only exception is if you want to try certain code fragments to see if something is possible without too much overhead)
Shadow Wolf
16
Years of Service
User Offline
Joined: 6th Jul 2008
Location:
Posted: 25th Jul 2008 18:23
Thanks for the help but I'm still confused on the code I need for the plane to shoot. Right now the plane shoots a simple sphere when you click the left mouse button but you have to hold it down for it to keep going and when you let go the ball goes right back to the planes coordinates. How would I be able to have the ball keep going continuously even after I release the mouse button and make a new ball when I click the mouse button again to repeat the process.

Login to post a reply

Server time is: 2024-09-30 03:32:29
Your offset time is: 2024-09-30 03:32:29