Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

Anyone know how to get the position and vector velocity of a vessel?


vessel.orbit.getPositionAt(Planetarium.GetUniversalTime()) * Planetarium.InverseScaleFactor;

That\'s what it seems to be but the values don\'t make sense pertaining to my current altitude.

Link to post
Share on other sites

Is there a way to see if a part has a stage before it? I need to make this part not run its Active functions until the stage before it is gone.

if (this.inStageIndex == StageManager.StageCount) 
{
}

This should check to see if the part is in the active stage. It looks like there are some other fancy stuff you can check in the stage manager.

Link to post
Share on other sites

if (this.inStageIndex == StageManager.StageCount)

{

}

This should check to see if the part is in the active stage. It looks like there are some other fancy stuff you can check in the stage manager.

Well, it\'s not so much active stage as 'is this part exposed' or 'is this part the last part in its stage'

Link to post
Share on other sites

I\'m starting work on a deploy-able balloon part. I\'ve got buoyancy working, but I want it to work like a parachute (deployable). Does anyone have an example of how to switch meshes like the parachute module?

[mod]Do not talk about decompiling the game. I will not give you a second chance.[/mod]

Anybody knows how to display pressure?

ooh, I can help someone!

this.staticPressureAtm & this.dynamicPressureAtm

I\'m not sure if this is correct, but it seems to work for density

FlightGlobals.getAtmDensity(this.staticPressureAtm)

Link to post
Share on other sites

I created an oxygen tank of sorts. I\'ve noticed that it gets used at the same pace, no matter what warp I use. How do I fix this?

If it\'s possible, try to get the warp multiplier, and adjust the oxygen exhaustion rate accordingly.

I\'m thinking something like.

public void adjustExhaust(<T> theWarpFactor)

{

if (theWarpFactor is something)

then set oxygen to certain speed something like

this.oxygenRate = theWarpFactor*this.oxygenRate

else

do something else

}

Excuse my really shitty psuedo code.

Link to post
Share on other sites

Does anyone have an example of launching a UI of some kind? UnityEngine.GUI, console window, etc...?

Try looking at r4am0n\'s and CardBoardBoxProcessor\'s MechJeb Autopilot. They have a GUI which you can see in their source code, you learn a lot by reading the code.

Then we have Unity\'s own documentation:

http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=gui

And some basic tutorial:

http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

How you apply it to KSP you\'ll have to figure out yourself, or by help from other people\'s source codes.

Link to post
Share on other sites

What\'s the difference between:

OnPartActivate, OnPartAwake, OnFlightStart, etc.?

Basically, a part I\'m using needs to initialize some variables each time it\'s loaded. I\'m putting it in OnFlightStart at the moment, but I\'m getting some very strange behaviour which I think might be due to one of those variables not being properly initialized.

Link to post
Share on other sites

OnPartActivate - happens when you press Spacebar and the stage with your part is activated.

OnPartAwake - I believe this is available when unpausing the game.

OnFlightStart - this happens when you click 'Launch' in the VAB and the ship is placed on the launch pad.

I\'m doing the initialization in onPartStart();

Link to post
Share on other sites

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...