Sign in to follow this  
mickeyren

shooting missle/falling bomb from a ship

Recommended Posts

Hi Please look at my demo game. or here in youtube(they are just the same). You can see the ship looks like its dropping poo. Anyway, what I want to achieve are 2 things. 1. A more realistic drop of bomb - i think i have to use a capsule shape and re orient the head to slowly point downwards while its falling 2. missile - this is probably hard, the effect i want here is the ship to sweep/swoop/fly over to the house and halfway near, it will fire a missile(again a capsule or cylinder shape), the missile will track to the target and fly towards it realistically. Thanks for your ideas.

Share this post


Link to post
Share on other sites
The biggest problem I see in that demo is that the bombs drop vertically, even though they were released from fast-moving aircrafts. The trajectory of a bomb should be roughly a parabola. Whether the bomb tilts downward or not will matter little compared to this violation of Newton's first law.

Share this post


Link to post
Share on other sites
bomb? trajectory? hmm... i imagine the bomb should just falling downwards, and its head orienting/tilting towards the ground no?

The missile would be release halfway when the ship is halfway through its target. I probably should do the following for the missile:

1. When fired, push it down a bit.
2. Have it seek to the target.

I think these may be just bunch of path interpolation. The bomb would probably just orienting its head.

Anyway, i'm still open to other ideas.

Share this post


Link to post
Share on other sites
"An object in motion stays in motion unless acted on by an unbalanced force."

If you drop a bomb from a plane it will have the same velocity of the plane. The reason it doesn't stay with the plane is because lift on plane balances with gravity so the plane doesn't fall. The bomb on the other hand will gradually fall with an acceleration of 9.8 m/s^2.

The easiest way to get the rotation matrix of the bomb is by using the velocity of the object. Meaning the bomb will point in the direction it's moving. This is the simplest way to do it.

Share this post


Link to post
Share on other sites
Immediately after being released, the bomb will have the same velocity (and hence direction of travel) as the plane. There are then two forces acting on the bomb: gravity and air resistance.

Gravity is simple, F_g = m * g, where m is the mass of the bomb (in kg) and g is 9.81 m/s^2. The direction of this force is down.

Air resistance is a bit trickier, but can be approximated by F_d = 1/2 * C_d * v^2, where C_d is the drag coefficient of the bomb in air, v is the speed of the bomb (length of the velocity vector). The direction of the drag is the opposite of the velocity.

Lower drag coefficient will make it arc more slowly than a higher drag coefficient.

In order to orient the bomb, you can simply rotate it so that the length of the bomb is parallel to the velocity vector (either figure out the angle or just construct a rotation matrix directly from the velocity vector). I think that'll look good.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lord Crc
Immediately after being released, the bomb will have the same velocity (and hence direction of travel) as the plane.


Hmm... I think I'm getting confused here.

The bomb shouldn't follow the same velocity as of the plane. I'm showing 2 images which shows the 2 types of behaviour i want to exhibit.



and



So I like a carpet bombing similar to the first screen shot.

I think you guys are pointing out how its suppose to behave on the second screen shot - but yes ill give that a try - without air resistance first. :)



Share this post


Link to post
Share on other sites
In your first image the bombs seems to drop straight down because the viewer is moving at the same speed as the plane dropping the bombs. The bombs fall under gravity but when they leave the plane they are moving forward at the same velocity as the plane. As soon as they leave the plane they will start to accelerate downwards (because of gravity). So the bombs follow a parabola, they don't drop straight down. The bombs will also loose some forward momentum because of air resistance, but you can probably ignore this for bombs dropped at low altitude.

Share this post


Link to post
Share on other sites
Quote:
Original post by mickeyren
Quote:
Original post by Lord Crc
Immediately after being released, the bomb will have the same velocity (and hence direction of travel) as the plane.


Hmm... I think I'm getting confused here.

The bomb shouldn't follow the same velocity as of the plane. I'm showing 2 images which shows the 2 types of behaviour i want to exhibit.



So I like a carpet bombing similar to the first screen shot.

I think you guys are pointing out how its suppose to behave on the second screen shot - but yes ill give that a try - without air resistance first. :)

No, they're not. The way they've described will perfectly model the 1st screenshot, as you want.

Quote:
If you drop a bomb from a plane it will have the same velocity of the plane. The reason it doesn't stay with the plane is because lift on plane balances with gravity so the plane doesn't fall. The bomb on the other hand will gradually fall with an acceleration of 9.8 m/s^2.


Read that over again and look at your screenshot.

In any case, here's a solution for you in simple math:

When a bomb is dropped:
bomb.position.x = plane.position.x
bomb.position.y = plane.position.y
bomb.velocity.x = plane.velocity.x
bomb.velocity.y = plane.velocity.y

Every time physics are updated:
bomb.velocity.y -= 9.8 * time_passed_since_last update (in seconds)
bomb.position.x = bomb.velocity.x * time_passed
bomb.position.y = bomb.velocity.y * time_passed

Note that it only uses gravity and ignores air resistance, which isn't that important to get what you want.

Share this post


Link to post
Share on other sites
Quote:
Original post by shurcool
In any case, here's a solution for you in simple math:

When a bomb is dropped:
bomb.position.x = plane.position.x
bomb.position.y = plane.position.y
bomb.velocity.x = plane.velocity.x
bomb.velocity.y = plane.velocity.y

Every time physics are updated:
bomb.velocity.y -= 9.8 * time_passed_since_last update (in seconds)
bomb.position.x = bomb.velocity.x * time_passed
bomb.position.y = bomb.velocity.y * time_passed


If you want to see that sort of physics in action, take a look at my Sopwith clone in Flash (a 2D side-view airplane fighting/bombing game).

http://www.cse.yorku.ca/~cs243104/Sopwith.swf Press F to take off, left/right arrow keys to turn, and B to release a bomb.

Share this post


Link to post
Share on other sites
When the bombs leave the plane, they don't travel straight down. They accelerate downwards at 9.8 m/s/s, but they travel horizontally at the same speed as the plane. Look at the first photo. When the first (lowest) bombs were dropped, they would have been directly below the plane. The plane has since dropped a bunch more bombs, so some time has passed, and the plane has kept moving forward, yet the first bombs are still directly underneath the plane! The bombs are accelerating downwards, but they're also continuing to move along underneath the plane at the same speed as it! Assuming the plane keeps travelling with the same velocity, the only reason the bombs won't stay directly underneath the plane until they hit the ground is because the air resistance (drag) on them will slow them down. The consequence of this is that the plane has to drop its bombs well before it actually reaches its target, otherwise it will overshoot.

1- 2- 3-
PLANE PLANE PLANE
BOMB1 BOMB2 BOMB3
BOMB1 BOMB2
BOMB1

The plane is moving from left to right across the textbox, and each bomb moves downwards, but also moves left to right with the plane! So in your game, when the bomb is dropped from the plane, make its velocity exactly equal to the planes, then each frame simply apply gravity and some air resistance to it.

If you want to test it, throw a rock straight out of a car window and watch where it lands. When it lands it will probably be closer to where the car is than where the car was when you threw it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this