# Hovering

Just a quick question- how do you create hovering in the game engine?

Add a plane above the ground plane and set as invisible. then have the player use the invisible plane as the one it walks on not the ground plane.

Hope this helps

What about other objects that I don’t want to hover?

This is what I do, create a “Always” logic brick and then connect it to a “Motion” brick and set the far right column in force to “9.80” and click the “L” next to it.I will upload a pic if you dont understand.

But wouldn’t that make me constanly go up?

It makes it levitating.

Another way is to set appropriate DYN values to the materials <F5> of the ground (Fh dist>0.0, Fh Force > 0.0). Enable “DoFh” at the rigid body object (<F4>).
The object will hover over the ground.

No it wont make it go up, 9.8 just negates the force of gravity

It’s been a while since i studied physics, but i believe the equation is W = mg, W is weight(The force that pulls down), m is mass, and g is gravity.

Gravity on earth, and the default gravity in blender is 9.8 newtons, so to negate the force of weight, which for an object with a mass of 1 would be W= 1 * 9.8 = 9.8, just put a force of 9.8 upwards along the z axis

as such with a higher mass you would need to calculate the weight again, for example, with a mass of 5, W would equal 5 * 9.8 which is 49.

Just set a ray sensor that senses anything with the property ‘ground’ on the -z axis. When it is triggered, have it go into a state where rigid body and/or the dynamics are suspended. Then, have the object always play a floating animation.

If you want it to be triggered by a player, just change the ray sensor into a keyboard sensor, then in the next state make another keyboard sensor to trigger out of it and go back into flying/falling mode.

what Purgarus is trying to say is that when a player presses a key have it go into a state where force is acted upon the player at the exact same speed, but opposite distance, of gravity. Pressing ‘L’ would make it local and not just upwards, so I’d leave off pressing ‘L’. DO NOT PRESS ‘ADD’. That will screw it all up and make your player gain speed instead of keeping a constant speed. You can find where the gravity settings are in the world panel.

Hope this is what you are looking for!-YA

Hey what would happen if I connected the main object to a invisible object below it?

That would make the same effect as the ray sensor does. When he is at a certain distance from the ground, he stops falling.

But back to the plane idea, how would I make it only apply to my character? Sorry but I don’t have any knowledge of ipo or anything outside of the game engine, so I’m trying to stay away from that sort of stuff.

Another way to have a ‘hovering’ object is to use the Distance Constraint Actuator. This even works on static objects.

This one basically puts your object on a certain distance on 1 axis from other objects. It even works on slopes (with the possibility to have it rotate along the normal of the floor).

A simple solution that doesn’t need invisible objects or require you to suspend dynamics

The floating force method described above is the best, most game engine accurate one, I believe. Also, you should really try to learn everything you can about Blender; don’t stay away from IPOs or anything like that, because the more complex the ideas you try to implement, the more you’ll have to use things like IPOs, Actions (both Shape and Armature), and Python.

If you want something to float in a fixed plane, regardless of what is below it, you can use a Constrain Location actuator, just constrain the Z loc to a certain value. Turn up the Dampen field to make it look bouncy.