I am new to Jme3 and I thought I would implement a box that acted similary to a hovercraft. So, every update, I do: setCenteralForce(new Vector3f(0, 100, 0) onto my “vehicle” controller. It seems to be that at first the box jumps up into the air, then gravity(it is set worldwide to -9.8f) takes over and it crashes down. Then, it sort of “hops” up in the air. What I was hoping for is that it would jump up, then go down, then jump up again, ect… I tried to use the physics tick listener rather than the update method, but the physics preTick “space” doesn’t have methods such as applyForce ect… I am not sure why. Also, for some reason the box doesn’t seem to care abiyt where I position it. I set the setLocalTranslation of it to -1000 (when the terrain is at -100) and it was still at the same location. Apologies for the messy code, I tried many things and commented them out. What methods / tequnchies should I be using for a floating-like effect?
Is there a way to set it to be a certain distance above the current ground? I did setImpluse(new Vector3f(0, 50, 0), new Vector3f(loc.x, loc.y - 2, loc.z);
where loc is getPhysicsLocation since the box is 1 in both direction for the y. However, the box keeps toppling over and it just isnt smooth…
So i thought I could do that then add a random.nextDouble() to make it look like hovering
Actually in my mind it seems reasonable it would do that if the impulse is too great.
You could try balance it using 2 (front back) or 4 (each corner).
It would probably need some interesting mathematical formula to determine the unit impulse required for each corner to balance the thing and keep it level.
You could start maybe by using the rotation of the object. If your object is rotated on the x axis at quarter pi or more, zero impulse is applied on the left side, and anything below quarter pi is between 0 and 1, which you can use as a mult for the impulse force.
I hope that makes sense. Welcome to the wonderful world of maths.
Oh wow… there’s no quick and easy way to hover then, I see… I was think for now I’d just do it when its completely level and apply an impulse of 2 on each corner. should that completely stablize it? I find it weird that applying an impulse to the center leavings one point on the ground… is that randomly determined?
Not really. But applying an “up” impulse is relative to the rotation of the object. Just like a helicopter, if the thing is upside down, up force becomes down force, and tilting slightly forward applies a rotated force to move it forward and up, and because the up force of a rotated vehicle is also now sideward force, more force is required to keep it up.
Physics in a computer is only a simulation of step-wise math. Normally forces balance out such that an object sitting on the ground doesn’t rock back and forth (though it will if accuracy is set low enough).
I think when you start lifting it off the ground, you capture some of that instability and things go out of balance.
…that being said, I’ve applied upward impulses to the center of things and they don’t spin. So it may be related to other things.
Ah… I see… apply a impulse to the 4 corners and the center still results in some “dancing-ness” although less… I’m not sure if anyone else has every created a hovercraft (I found one ancient thread on it from '08)
yes, using tpf makes it not rotate but its not as smooth as I would want to be… animation is what I think I will do… I’m not exactly sure how to use blender so I would have to use motion-events then, but not sure what ocordintaes to use for that, so maybe I’d use blender animations then
EDIT: Nevermind, the Jme3 beginner tuts have good info on animation