日期:2014-05-17 浏览次数:20909 次
public void FireMissile()
{
foreach (GameObject missile in missiles)
{
if (!missile.alive)
{
missile.velocity = GetMissileMuzzleVelocity();
missile.position = GetMissileMuzzlePosition();
missile.rotation = missileLauncherHead.rotation;
missile.alive = true;
break;
}
}
}
public Vector3 GetMissileMuzzleVelocity()
{
Matrix rotationMatrix = Matrix.CreateFromYawPitchRoll(missileLauncherHead.rotation.Y, missileLauncherHead.rotation.X, 0);
return Vector3.Normalize(Vector3.Transform(Vector3.Forward, rotationMatrix)) * missilePower;
}
public Vector3 GetMissileMuzzlePosition()
{
return missileLauncherHead.position + (Vector3.Normalize(GetMissileMuzzleVelocity()) * launcherHeadMuzzleOffset);
}
private float gravity=0.98f;
void UpdateMissiles()
{