The following code is attached to a bullet which is a rigidbody.
static var speed;
private var coeff;
private var dragvalue;
private var alpha;
private var bullarea;
private var secden;
private var balcoeff;
private var masses;
function Start()
{
speed = 868;
coeff = 0.1;
dragvalue = 2;
alpha = 1.1839;
bullarea = 1.086;
secden = 0.16;
balcoeff = 0.17;
masses = 0.535;
}
function Update ()
{
if ((speed > 1544)&&(speed<=1699))
coeff = 0.09;
if ((speed > 1390)&&(speed<=1544))
coeff = 0.103;
if ((speed > 1235)&&(speed<=1390))
coeff = 0.109;
if ((speed > 1081)&&(speed<=1235))
coeff = 0.12;
if ((speed > 926)&&(speed<=1081))
coeff = 0.135;
if ((speed > 772)&&(speed<=926))
coeff = 0.15;
if ((speed > 618)&&(speed<=772))
coeff = 0.165;
if ((speed > 463)&&(speed<=618))
coeff = 0.19;
if ((speed > 309)&&(speed<=463))
coeff = 0.21;
if ((speed > 154)&&(speed<=309))
coeff = 0.07;
if ((speed > 0)&&(speed<=154))
coeff = 0.06;
if (speed <= 0)
coeff = 0;
dragvalue = 0.5 * alpha * (speed*speed) * bullarea * (coeff*(secden/balcoeff));
var newval = dragvalue/masses;
speed = speed - (newval * Time.deltaTime);
velocity = transform.TransformDirection( Vector3(10, 0, speed ) );
}
When fired however i dont believe this is actually adjusting the velocity of the projectile. Could anyone give their opinions on this matter?