Water Rocket Project - Decreasing Mass and Force?

Hey,
For my physical science class, I’m working on a moderately accurate way to launch a 3d model representing a rocket, have it run out of force and mass, and crash to the ground. I’ve created a model, added a box collider, and am currently working on scripting so that the rocket loses all the water’s mass and force in a given number of frames, then fall back to earth. For some reason, it jumps up only slightly, falls back to the terrain, then vibrates around and eventually falls through the terrain, even though both colliders are working as they should.

``````var emptyrocketmass = 0.05; //Mass of the empty rocket.
constantForce.force.y = 450; //Newtons
var thrustloss = 1; //How quickly does the rocket lose thrust and mass? (Lower = faster)
var massloss = thrustloss; //Lose water mass as fast as thrust
rigidbody.drag = 0; //Drag (In Newtons)

massloss = rigidbody.mass / massloss;
thrustloss = constantForce.force.y / thrustloss; //Determines that in n frames, the rocket will run out of water to force out, and therefore it'll lose mass and thrust.

function Update () {
rigidbody.mass = rigidbody.mass - emptyrocketmass; //temporarily removes rocket's mass so that the new mass can be calculated
rigidbody.mass = rigidbody.mass - massloss; //Decreases mass
rigidbody.mass = rigidbody.mass + emptyrocketmass;
constantForce.force.y = constantForce.force.y - thrustloss; //Decreases force, too, so acceleration SHOULD decrease.
}
``````

As long as you want the water to be lost at a uniform rate, I would just do something like this…

``````var FullMass : float = 5.0;
var EmptyMass : float = 0.05;
var RocketForce : float = 500;

// Time (in seconds) until all the water is gone...
var WaterLossTime : float = 1.0;
var ForceLossTime : float = 1.0;

// The actual counter for the water loss
private var WaterLossTimer : float = 0;
private var ForceLossTimer : float = 0;

Function Update() {

var InstantaneousForce : float = ( 1 - (ForceLossTimer / ForeLossTime ) * RocketForce;

var InstantaneousMass : float = ( FullMass - (FullMass / (WaterLossTimer/WaterLossTime))+ EmptyMass );

rigidbody.mass = InstantaneousMass;
rigidbody.AddRelativeForce( Vector3.up * InstantaneousForce * Time.deltaTime );

ForceLossTimer += Time.deltaTime;
MassLossTimer += Time.deltaTime;

}
``````

Try that…