hi folks,
i’m busy with a side project to understand how to animate objects in unity with scripts.
so i started with something simple… a space rocket.
i did some research about rockets and space shuttles about the way they move.
the most stuff was easy… but now i got some little problem i can’t get fixed.
my rocket moves up just fine.
but it has to rotate a little and move along the LocalPosition, but it wont move along the LocalPosition.
var force : float;
var speed = 0.0;
var gravity = -0.0098;
var drag : float;
//-------heights-------//
var grondheight = 0.0;
var midairheight = 100.0;
//-------*heights*-------//
function Update ()
{
if (speed > 0)
{
transform.localPosition.y += speed;
}
else
{
if (!isGrounded())
{
transform.localPosition.y += speed;
}
}
if (!isGrounded())
{
transform.position.y +=gravity;
}
speed += force;
//gravity = 1/transform.position.y;
drag = 0.0002/transform.position.y;
speed = Mathf.Max (0,speed-drag);
if (transform.position.y > grondheight)
{
force = 0.0025;
}
if (transform.position.y > midairheight)
{
force = 0.005;
}
if (speed > 0.40)
{
transform.localRotation.x += 0.001;
}
print(drag);
}
function isGrounded():boolean
{
return(transform.position.y <5.0);
}