Helicopter Movement

Dec 25, 2007 at 10:15 AM
Hi All,
I am trying to make a arcade side-scrolling paratroopers kind of game with a helicopter as the main player control using Farseer Physics Engine.
The movement of the player is controlled by the keyboard. As given in the example, I apply force when a key is pressed. But when the key is released the gravity comes into effect on my player eventually making the helicopter touch the surface. If I keep the gravity zero, then then the helicopter has the same force and continues in the same direction of the initial force. I actually need to have gravity in the game so my bombs and paratroopers can go towards the surface while my helicopter should stay in the air... How would i be able to achieve this behavior of helicopter with the physics engine?
Any pointers would be very much appreciated.
Coordinator
Dec 25, 2007 at 11:00 AM
Well, there are 2 solutions:

1. The newest release of Farseer has a IgnoreGravity property on the Body object (just saw this in the release notes).
2. Don't use the helicopter as a physics object, but just as a simple sprite (texture). This way you could manually check for intersections (collisions) on other objects. The helicopter does not need to be a physics object since it does not require gravity/mass (also bouncing off other objects is not required i presume).
Dec 25, 2007 at 11:19 AM

genbox wrote:
Well, there are 2 solutions:

1. The newest release of Farseer has a IgnoreGravity property on the Body object (just saw this in the release notes).
2. Don't use the helicopter as a physics object, but just as a simple sprite (texture). This way you could manually check for intersections (collisions) on other objects. The helicopter does not need to be a physics object since it does not require gravity/mass (also bouncing off other objects is not required i presume).


Thanks for a speedy reply. I just tried using IgnoreGravity before seeing this thread, and as expected it doesn't go down, instead the helicopter moves steadily in the direction of initial force having a very less reduction in the linear velocity.
How can we get over this?

As per the 2nd option, we need the helicopter to collide with different objects and may be bounced off after collision based on the object it collides or explode.

Is there any other way to get this accomplished?
Coordinator
Dec 25, 2007 at 11:53 AM
I'm not sure on how the IgnoreGravity works, but it may not be possible to change the friction of the physic objects when the gravity is ignored. Try it out.

With the second option, you still have the posibility of "bouncing" the helicopter away from the objects it collides with. The bouncing would just not be handled by the physics engine, and that may be preferred.

Here is an example of what will happen when using the physics engine:
If the helicopter collides with a tree with high velocity (and does not explode) the helicopter would bounce back according to the angle (The normal) the helicopter collided with the physics object.

There is a third way. But this solutions is more of a hack than a real solution.
The purpose of the physics engine is to update the position and rotation of the physic objects. You could ignore the position and rotation of the helicopters physics object and control it by your self. You can still check for collision between the helicopter and other objects and respond with the appropriate reaction. (like stop ignoring the position coming from the physics engine when a collision occurs, this would make the helicopter bounce)

Just be creative in the usage of the physics engine, you must figure out excatly what reaction the helicopter should have when encountering other physic objects, this could contribute to the final solution you come up with.
Dec 26, 2007 at 10:09 PM
To me, it looks like you could just maintain a constant upward force on the helicopter due to its spinning blades, as in real life. The force would be equal to the gravitational force when the helicopter was just hovering, but would increase if you wanted to increase altitude, and decrease to descend. I assume you are already applying upward/downward forces whenever you press the up and down keys. You just need to have a constant upward force equal to gravity that you add to these before you apply them.