Jump to content
  • Advertisement
Sign in to follow this  
Ashaman73

A tank game and the problem of the projectile flying path

This topic is 3758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm in need of some advices :) My current hobby project is a tank game and with it comes my current problem: aiming and shooting Background: You control you tank from a top-down like view. You use the keyboard (asdw) to move it, your mouse to turn the turret and finally your mouse button to shoot. Well, the gameworld consists of a 3D world (terrain, buildings..) and a physic engine for tank movement, projectile movement, hit detection etc. The problem: How to hit your target ? Imaging, your target is upon a small hill. From a fps perspective you would aim at your target by lifting your gun and predicting an flying arc of your projectile. But from a top-down view it is too difficult to aim by lifting your gun. So far I've come up with some ideas to solve this problem. 1. auto aim I just determine the first target in my line-of-sign of the gun and calculate the correct flying arc to the target. Pro: very easy aiming Con: just too easy, where is the challange to hit an opponent ? 2. flat world Just model your world flat. You can shoot along the x-z plane and there're only obstacles which you can't overcome. Pro: easy aiming Con: a flat world is just not what I imagine 3. strong/high flying arc Your projectile always flies at a higher arc, like artillery. Pressing your mousebutton longer will result in a higher, longer flying arc. Pro: challanging aiming, you can almost hit everything even behind obstancles or on hills. Con: hitting a moving target directly is difficult, any target under the flying path will not be hit I personally prefer number 3 so far, but this solutions comes with its own restrictions. The aiming must be accurate, you have to introduce splash damage (else it would be too hard to hit) and the projectile would fly much slower (remember, I use a physics engine to move the projectile !). What is your adive ? Have any idea to do it better ? Other ways I don't though of ? -- Ashaman

Share this post


Link to post
Share on other sites
Advertisement
I would just go ahead and allow up/down aiming with specific keyboard/mouse controls. Either show a reticle on the ground for the estimated drop point, or show an estimated launch-arc (very beginning of the projectile path). The reticle would allow precise aiming, while the launch-arc would create some trial and error shooting. Personally, I belive the launch-arc would be more fun.

Share this post


Link to post
Share on other sites
If the world is 3D, why are you using top down? Why not use a first or third person view so you can actually aim.

Share this post


Link to post
Share on other sites
Will you have a pretty good idea of the lay of the land? Here's what I'm thinking, but you'd have to know relative altitudes pretty well.

When you click to fire, have the tank fire at the appropriate elevation/power to hit that point at your altitude, in windless conditions, so if you're on a flat plain, it's a simple matter of clicking on your targets, but if there's variance in the terrain, you've got to guess how far in front or behind them to aim.

If you've got wind, that's another wrinkle. If you get to control both your elevation and shot power, then have the elevation controlled by the scroll wheel or something, and then do the power thing with the distance of the click.

Share this post


Link to post
Share on other sites
I had played a online WW2 tank game between Russian and Germans (can't remember the name). The game has a top-down view with an aiming mechanism that fits what you want.

1) Different guns have different rate of fire.
2) Mouse used for aiming left-click for firing.
3) When you click to fire, the trajectory will be automatically calculated and the shell will fly towards the target. It is not a guarantee hit as the opponent is able to maneuver his tank and spoil your aim.
4) There is a pendulum swinging when you are aiming and will stop when you click to fire. The position the pendulum stops when you are firing will determine how much damage you will dealt to target if the shell hits. There are three outcomes:
- Extra damage (small chance)
- Normal damage (more then half chance)
- Less damage (very small chance)

This control scheme allows players to move your tank and shoot at the same time. The challenge of clicking at the right moment should be sufficiently challenging yet not too hard for the player.

Share this post


Link to post
Share on other sites
If you have the Mousewheel as part of your input, you can make it so that its up or down wheeling will raise or lower the gun and subsequently adjust its shot power as well to compensate for aiming at the same targeted point - in this way you can have a wide range of shots including the low, straight, quick shot, or the slower but more powerful artillery-like arc-fire that goes over obstacles and walls which primarily uses gravity.

If you aren't factoring Mousewheel in, you could allocate two keys to do the same up and down raising (such as two keys next to your main movement keys). How I personally do the keys is instead of the WASD keys for movement, move that over to RDFG to free up your pinkie, giving it access to the Q, A, Z, S, and etc keys - "Q" can then be Raise Gun Angle and "A" be the lowering. In this way you won't have to move your main three fingers away from the movement keys while angling the gun.

If you have multiple guns, they would all be raised or lowered at once, otherwise it would get too complicated.

The line/arc of firing can also be shown on the screen (as a solid or dotted bright line) so that players can tell how high their gun is angled at. Make it so that the higher you aim the gun, the more dotted the line gets (besides it becoming more sloped).

I would avoid having to hold down the mouse button to determine firing angle, for it would hinder the firing process, and make it a bit more frustrating, I would think, because then it would become a game of timing the raising of the gun to a desired position rather than the timing of the shooting of the projectile to land on a moving enemy. As well as that, it isn't really realistic to think that your gun's firing angle would reset each time it fires (it should stay on the angle it last fired on) and how it would continually go up or down until you tell it to stop.

[Edited by - Tangireon on June 11, 2008 6:18:33 PM]

Share this post


Link to post
Share on other sites
wow, great input :)

@JasRonq: it start out as 3d fps tank game, but I've one major problem. I can't provide enough detailed artwork to make it acceptable good from a fps perspective.
I want to concentrate more on game logic than making artwork, btw, I really enjoy top-down tank games, dont know why ;-).

@Si Hoa
@Iron Chef
Both of your ideas sounds good, but I think that I tend to not to use the mouse pointer for aiming. Aiming with the mouse has a taste of 'arcade' whereas aiming
without the mousepointer is more action based. I imagine a 'tank' game like battlefield 1942 without aircrafts and infantry from a top-down like view.

@Tangireon
@Kest
You have me convinced to raise the gun for aiming. The visualization of the lunch arc is a very good idea.


So far I tend to use the following aiming mechanism:
Aiming by turning the turret and raising the gun.
Raising the gun results in a higher/longer flying path.
Pressing a button results in firing the projectile independent who long you have pressed it.
The predicted launch arc will be visualized.

Still there're a few open questions:
1. How to raise/lower the gun ? I dislike the idea of pressing some keys. I would like to aim and fire with the mouse.
So is it praticle to turn the turret by moving your mouse left-right and to raise/lower your gun by moving your mouse up-down, or will it ends in chaos ?
On the other hand, if you use the mousewheel you need to take your finger from your left mousebutton (firing button), won't this disturb the gameflow ?

2. How to do the visualization of the launch path ?
Considering that this is a top-down like view (think of very high third person view). I'm looking for a intuitive visualization which stays in focus of the player.
So a dotted line pointing from your gun and getting more solid if you raise the gun is a good start, but is it really intuitive ? Changing color ?
A translucent triangle fromed from the launch line and the tank look-at vector ?

Share this post


Link to post
Share on other sites
If the tank is allways in the centre of the screen it is possible to let the distance between the cursor and the tank determine the angle. If the cursor is close to the tank it aims up and if its far away it aims down, or reverse. It is more "analouge" than the mousewheel.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!