Page 1 of 1
Gravity-less vehicles
Posted: Sat Sep 17, 2011 5:24 pm
by hipnox
Hello,
Is it possible to make a vehicle immune to gravity? I need to spawn vehicles similar to the Prince of Wales in the air and not have them plummet to earth.
I tried with the ObjectTemplate.GravityModifier 0 but did not work.
Any ideas?
Re: Gravity-less vehicles
Posted: Sat Sep 17, 2011 9:04 pm
by Apache Thunder
There is a global command that turns of gravity for everything, but something tells me you only want this for specific vehicles. Setting mass to zero might work (never did this on any of my vehicles so I can't tell you for sure if that will work or not).
You can also use the holdObject command to hold the vehicles to the spawner:
(use this on the spawner that spawns the vehicle, not on the vehicle itself!)
It only works until someone tries to drive the vehicle. Then the spawner will release it and it will fall to the ground.
Re: Gravity-less vehicles
Posted: Sat Sep 17, 2011 11:41 pm
by Senshi
mass is a tricky thing. It's not what one would except from real life. It has a multitude of effects, all of them weird and squishy-squashy, kinda. Setting it to 0 will definetly not keep your object from falling.
There are two other possibilities: For static objects you can use Apache' method (if it's only intended to hang around and nobody should be able to drive it, you'll have to set Mobilephysics to 0 as well).
The other possibility is to add FloatingBundles to the object. This is definetly CSM and requires a lot of fine-tuning and trial&error to find good values that keep the object correctly in mid air, especially during movement.
Posted: Sun Sep 18, 2011 1:04 am
by freddy
Apache Thunder wrote:
(use this on the spawner that spawns the vehicle, not on the vehicle itself!)
It only works until someone tries to drive the vehicle. Then the spawner will release it and it will fall to the ground.
this, and then give the engine another (phony) input "c_PIReload" or whatever
Re: Gravity-less vehicles
Posted: Sun Sep 18, 2011 1:46 am
by hipnox
The idea is to have battleships flying at very low speed, and i dont think any amount of wing lift is going to keep a Prince of Wales flying at walking speed. Hence, no gravity would be usefull.
Will try the float thingy, but if that doesnt work, i might need to go the stationary rout and us the hold command.
Re: Gravity-less vehicles
Posted: Sun Sep 18, 2011 4:57 am
by Swaffy
The Pelican airships in the HomeFront mod have no gravity. Look at those.
Image: [
Link]
Re: Gravity-less vehicles
Posted: Sun Sep 18, 2011 9:47 am
by Senshi
If they have to move, FloatingBundles are your go.
Code: Select all
rem *** PrinceOW_Floater ***
ObjectTemplate.create FloatingBundle PrinceOW_Floater
ObjectTemplate.setHullHeight 17 <----defines the height above water the object should try to maintain. Set this to 100 or sth. for flying.
ObjectTemplate.setFloatMaxLift 2 <----this is the maximum push-upwards-power the floater can apply on the object
ObjectTemplate.setFloatMinLift 2 <----this is the minimum of above. Keep both at the same value for stable flying (very important!)
The tricky part is getting the right Lift values, as the Lift strength is related to the gravity. For that, it's useful to know that BF42 uses not the approximated 10N as most other physics engines do, it uses the more precise 9.9 (IIRC, not 100% certain). So, in order to counteract gravity, your floaters have to be exactly as powerful as gravity! So if you use the floater 4 times in order to stabilize the ship (that always is a good idea, just place them at -50/0/50, 50/0/-50, -50/0/-50 and 50/0/50 or sth., depending on size of main object. They ar invisible and non-collisionable anyway), you'd need to divide gravity by 4 and then use that value for the Lift values.
Now, this still seems straightforward. But you still have mass. Somehow mass is applied to gravity before your floaters, so the downwards pull from gravity is always somewhat stronger, it seems. As said, this is hard to figure out by formula and more of a trial&error approach. You can set mass to 0, but that can have unintended sideeffects as weird behavior on collisions. Another thing that comes into play: Air. Air has the stupid property of resisting moving objects, called Drag. Best set this to zero as well, at least for testing initial function. Shouldn't hurt much anyway as your ships should move slowly anyway. This can become a huge problem with "ghost" aircrafts, though, that should keep level.
But with this approach you should get basic functionality. You might notice "jittering" (ship moving up and down), this means you have to adjust the Float Lift values. You also might notice the ship slowly losing/gaining altitude. In that case, again, visit the Lift values and reconsider your mass settings. setting mass to 0 also means that your ship, like a balloon, can be tipped out of its flightpath very easily and will probably be unable to return to a stable height and flight.
Re: Gravity-less vehicles
Posted: Sun Sep 18, 2011 4:33 pm
by hipnox
The floater thing worked. Thanks
Now i'll have to figure out how to control it and how to keep the AI from leaving the battlefield with it