Jump to content

MunMover problems.


Recommended Posts

So i\'ve been trying to update and improve the MunMover plugin to be able to move both the Mun and Minmus and to allow solar orbits. When I load up the flight scene with the part attached, I get several issues, including a non-loading vessel (screen turns sideways, pointed at the air, and velocity and altitude do not load) and a lack of mun-moving power.

Here is my code:


using UnityEngine;

public class MunMover : Part
{
CelestialBody body;
CelestialBody orbiting;
CelestialBody kerbin;

Orbit mo;
Orbit so;

public float SemiMajorAxis;
public float BodyToMove;
public float BodyToOrbit;
public float Inclination;
public float Eccentricity;

protected override void onPartAwake()
{
kerbin = FlightGlobals.Bodies[1];
body = kerbin.orbitingBodies[(int)BodyToMove];
orbiting = FlightGlobals.Bodies[(int)BodyToOrbit];

so = orbiting.orbit;
mo = body.orbit;

if (BodyToOrbit != 0 || BodyToOrbit != 1)

BodyToOrbit = 1; //If invalid BodyToOrbit parameter (i.e. not 0 or 1), set to 1 (Kerbin))

if (SemiMajorAxis == -1 && BodyToMove == 0 && BodyToOrbit == 1)

SemiMajorAxis = (float)(orbiting.Radius + 11400000); //If undefinied SemiMajorAxis for Mun (BodyToMove == 0), set to default


if (SemiMajorAxis == -1 && BodyToMove == 1 && BodyToOrbit == 1)

SemiMajorAxis = (float)(orbiting.Radius + 4640000); //if undefined SemiMajorAxis for Minmus (1), set to default


if (Inclination == -1 && BodyToMove == 0)

Inclination = 0; //set inclination to default if no inclination specified


if (Inclination < 0 && BodyToMove == 1)

Inclination = 6;


if (Eccentricity < 0 || Eccentricity >= 1)

Eccentricity = 0;



base.onPartAwake();
}

protected override void onPartStart()
{
// Will probably only work when on or orbiting Kerbin

if (BodyToMove == 0)
{
print('Let\'s move the Mun!');
}
if (BodyToMove == 1)
{
print('Let\'s move Minmus!');
}

mo.semiMajorAxis = SemiMajorAxis;
mo.inclination = Inclination;
mo.eccentricity = Eccentricity;
mo.referenceBody = orbiting;


}
}
using System;

My cfg parameters are as follows:

// --- munmover parameters---

SemiMajorAxis = 20301660384

Eccentricity = 0

Inclination = 0

BodyToMove = 1

BodyToOrbit = 0

So what\'s going on?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...