Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

Hi! I would like to know if i can use unity 4.6.5 to make a mod, because the ksp modding tutorial says i have to install a 4.3 version

The current version of KSP (1.0.2) runs with Unity engine version 4.6.4f1, so I would suggest to get that one.

Link to comment
Share on other sites

If you know the location to place a Konstruct, do you know the Lat/Long?

I believe that if you know the Lat/Long there are methods in the CelestialBody class to convert to a vector point.

D.

Link to comment
Share on other sites

If you know the location to place a Konstruct, do you know the Lat/Long?

I believe that if you know the Lat/Long there are methods in the CelestialBody class to convert to a vector point.

D.

OK cool. Yes I can find out the lat/long for those places, Thanks.

Link to comment
Share on other sites

Does anyone have any pointers in using the GeneratesHeat flag on ModuleResourceConverter? Specifically around controlling the amount of heat generated. The best that I can tell, the only other input into the system is a TemperatureModifier field, which appears to just be a dimensionless scalar multiplier. Is there anyway I can specify "This conversion produces x Joules of heat energy"?

Specifically, I want to make some MM patches to convert the stock Fuel Cells to use CRP resources (Hydrogen, Oxygen, Water). That itself is straightforward, but I also want to generate heat as a byproduct, the question is how to accurately model that.

On a related note, I also want to add Hydrogen and Oxygen "evaporator" converters to the fuel cells, which consume LqdHydrogen and LqdOxygen and produce Hydrogen and Oxygen respectively; again, that is straight forward, but I would also like to absorb heat from the part to do so, so I set GeneratesHeat to true and TemperatureModifier to a negative value, which seems to have the correct effect of lowering the part's temperature when the evaporator is active. That seems kind of hacky though, any potential pitfalls with doing that? Also, is there a way to control the flow of output resources so that any Hydrogen or Oxygen generated by the built-in evaporators can only be used by the Fuel Cell?

Link to comment
Share on other sites

The TemperatureMultiplier value is multiplied with the part's thermal mass, that's how many kilowatts of energy get added to the part.

Which implies that a negative TemperatureMultiplier should work fine, but I don't know for sure.

There are some other relevant KSPFields here - there's a HeatThrottle parameter that presumably controls whether or not the part slows down as it gets warm (or cold?)

Link to comment
Share on other sites

Hi,

I am trying to make a mod that will change sounds for some of the stock engines and engines in other mods.

I want to do this without overwriting files but all I have found on the internet regarding modifying sounds for engines involves placing the sound files inside the part folder. Is that the only way to do it? Is there no way to add sounds without having to modify original Squad folders and other mod folders? Ideally, I'd like to have my own mod folder with a bunch of sounds in it, and use Module Manager to change the sounds to mine if the parts exist.

Link to comment
Share on other sites

Hi, so I have this problem spawning parts:

Notice the warp that happens just as physics enable? Anyone know what this is caused by? Vessel posistion, Protovessel posistion, orbit? something else entirely?

Link to comment
Share on other sites

The TemperatureMultiplier value is multiplied with the part's thermal mass, that's how many kilowatts of energy get added to the part.

Which implies that a negative TemperatureMultiplier should work fine, but I don't know for sure.

There are some other relevant KSPFields here - there's a HeatThrottle parameter that presumably controls whether or not the part slows down as it gets warm (or cold?)

Thanks, I'll have to look into it some more, there seem be some more multipliers (HeatProduction, InternalHeatProductionFactor, etc.) that really confuse what the units of TemperatureModifier are meant to be (and thus what it would physically represent). But if the end result are kilowatts, then from my reading of the calcs, TemperatureModifier and the rest should multiply out to units of Kelvin.

Also, is there a way to control the flow of output resources so that any Hydrogen or Oxygen generated by the built-in evaporators can only be used by the Fuel Cell?

Answering, my own question here: from testing it out it appears that setting a FlowMode = NO_FLOW on the OUTPUT_RESOURCE produces the intended effect.

Link to comment
Share on other sites

I have a followup to my question.

When loading vessels on the launch platform, the posistion can change whether you launched it, or came from the space center. (slight ...)

this.part.vessel.GetTransform().posistion is -12,8 0 8 when launching vessel from vab

this.part.vessel.GetTransform().posistion is 0 0 0 when returning to same vessel on launchpad from Space Center

How can i always get the first position result?

Link to comment
Share on other sites

I have a followup to my question.

When loading vessels on the launch platform, the posistion can change whether you launched it, or came from the space center. (slight ...)

this.part.vessel.GetTransform().posistion is -12,8 0 8 when launching vessel from vab

this.part.vessel.GetTransform().posistion is 0 0 0 when returning to same vessel on launchpad from Space Center

How can i always get the first position result?

I suppose the transform of the vessel is the transform of the root part? There seems something buggy about this object on load vs launch (launch seems fine, on load TweakScale has problems with it, looks like mod code is executed before it is set up correctly). If it gives a zero value, you might get what you expect if you read it later.

Link to comment
Share on other sites

Can you give other parts the ability to see their position on the right-click menu?

If so, those should be non-zero and would have values in them.

I ask because AFAIK, when you spawn a new flight scene, the vessel (so root part) is placed at world position 0,0,0 but that immediately starts changing as Kerbin is rotating. So depending on how long after the flight scene starts that you right-click the menu to see the location I would expect you to get different values displayed.

Also note that vessel.GetTransform().position simply returns the position of the root part of the vessel, there is no actual vessel object to get a position of. (It may also use the current ControlFromHere part, I'm not 100% sure which.)

D.

Link to comment
Share on other sites

Hey guys, a simple one here - where do I find the default settings for starting a new career/science mode game? I'm looking to force the startup science to a certain amount. Couldn't find the relevant section in the API. Thanks

Check in GameParameters, it holds all of the difficulty settings. The sub-class CareerParams has most of the relevant career mode options (rewards, science, starting amounts, etc...).

GameParameters.GetDefaultParameters() will give you the the default parameters for a given game type and difficulty level.

Link to comment
Share on other sites

Thanks, how much later?

The ship is waiting on the pad, untill I click the parts' right click menu to read the position.

Oh, ignore me then. My idea was about strange behavior while loading the ship. Once you see it on the pad and can use right click menus everything should be fine.

Link to comment
Share on other sites

Can you give other parts the ability to see their position on the right-click menu?

If so, those should be non-zero and would have values in them.

I ask because AFAIK, when you spawn a new flight scene, the vessel (so root part) is placed at world position 0,0,0 but that immediately starts changing as Kerbin is rotating. So depending on how long after the flight scene starts that you right-click the menu to see the location I would expect you to get different values displayed.

Also note that vessel.GetTransform().position simply returns the position of the root part of the vessel, there is no actual vessel object to get a position of. (It may also use the current ControlFromHere part, I'm not 100% sure which.)

D.

The thing is, that when I launch from VAB, everything works perfectly over and over. Leave it on the launchpad, goto spacecenter and come back, the position is now calculated with the wrong result. Same ship, hasn't moved an inch on the pad ( i realize it moves in relative terms because its a sphere, but my readouts are constant the first time).

I actually use this.part.transform.position to get the position I want, and create a new transform from that + a small vector offset.

It just dosn't return the same result =/

Link to comment
Share on other sites

That's because the origin point (0,0,0) isn't fixed in space. From what you're saying, it initialises slightly differently depending on how you transition to the scene (and is constantly shifting in flight)

This may help

FloatingOrigin.Offset

Link to comment
Share on other sites

Thanks, Looking at it, I get the following:

#Working (Launch Scene)

origin = "(-278.3, -3.2, -351.4)"

this.part.transform.position = "(-5.2, 0.0, 3.6)"

#Incorrect (Resume Flight Scene)

origin = "(-280.4, -3.1, -350.0)"

this.part.transform.position = "(-3.1, 0.0, 2.1)"

#Working (New Launch Scene)

origin = "(-278.3, -3.2, -351.4)"

this.part.transform.position = "(-5.2, 0.0, 3.6)"

Pretty consistent, yet the differences don't seem to add up, can you elaborate on its function?

Same process, different vessel, looks like this:

Link to comment
Share on other sites

From those numbers: origin + position = (-283.5, -3.1, -347.9) or (-283.5, -3.2, -348.0)

I find it likely the slight difference would disappear if you printed the result after adding the two Vectors together (much less rounding involved)

I believe FloatingOrigin.Offset gives the location of the origin relative to the last origin (other than after scene load, the magnitude is always 6000 which is the distance the origin shifts while krackensbane is not engaged) when it is shifted.

All the difference demonstrates is that the origin initialises differently depending on how you enter the scene which is why the part position is slightly different

Edited by Crzyrndm
Link to comment
Share on other sites

You have to understand the game use multiple coordinate system. The 0 moves around and is centered on the ship on load. The difference between your test may comes from the rotation too.

The question is : what are you trying to do ? If you want to move relative to a part position then

Vector3 offset = new Vector3( 1, 0 ,0);

Vector3 worldPosition = part.transform.TransformPoint( offset );

That will give your a position relative the the local coordinate system of the part to a world coordinate system.

Have a look at http://docs.unity3d.com/ScriptReference/Transform.html

Link to comment
Share on other sites

You are indeed completely right Crzyrndm. The difference is gone :D (should've seen that)

sarbian, that is exactly what I'm trying to do, but it should also follow the parts rotation, so it spawns in precisely the same spot relative to the part each time.

I'll take a look at it.

*edit

Vector3 worldPosition = this.part.transform.TransformPoint(_spawnOffset);

#Resume

worldPosition = "(-4.9, 0.0, -0.3)"

#Load new

worldPosition = "(-6.9, 0.0, 1.1)"

#Resume

worldPosition = "(-4.8, 0.0, -0.3)"

Relative to the part's system, should they not be static?

Excuse my comments, no idea if they're right.


Vector3 worldPosition = this.part.transform.TransformPoint(_spawnOffset);
//Get launch transform posistions
GameObject launchPos = new GameObject();
launchPos.transform.position = this.part.transform.position;
launchPos.transform.rotation = this.part.transform.rotation;

//Get Transform
Transform launchTransform = launchPos.transform;

//Extract ToAngleAxis data from selected spawning location
launchTransform.rotation.ToAngleAxis(out angle, out axis);

//TRANSFORM localRootPart posistion and apply offset
_newConstructRootPart.localRoot.transform.Translate(launchTransform.position + _spawnOffset, Space.World);

//TRANSFORM Rotate localRootPart in relation to root
_newConstructRootPart.localRoot.transform.RotateAround(launchTransform.position, axis, angle);

Edited by TAz00
Link to comment
Share on other sites

They're static relative to the part. As sarbian says, the position of the origin changes. Five units right of the part will always be five units right of the part: relative positions are preserved. But absolution position is not preserved, because the very origin of the universe shifts (to avoid FP issues). Always rely on relative positions, not absolute positions.

Link to comment
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...