Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

I'm trying to extend RCSBuildAid to include a center of Buoyancy function. It looks like it should be simple as Part has a CenterOfBuoyancy field, as well as a PartBouyancy. Unfortunately nont of these seem to be initialised in the editor. Does anyone know how to either initialise them or calculate it manually?

Link to comment
Share on other sites

I have updated my part to 1.2 and its showing very odd phenomenon.

One is, it gets some strut menu when specific code is included in plugin. Such as OnInitialize or OnLoad etc.

And now, its not showing in editor but it shows up after i start flight. And until the part is first enabled.

The two is, when timewarped short, it disappears. But its not. It follows the craft far back. 

I think these are some joint update related problem and Im not getting any sense. If anyone knows how does it work and has any tip.

Link to comment
Share on other sites

I'm looking to get into modding and have unity, but I am daunted by all the different tutorials and forum pages. I want to mod 1.2 but don't know where to start.

I'm moderately new to KSP (since 1.1) but have a little JS experience and am learning blender. I just want to create my own personal parts. Could you steer me in the right direction?

Link to comment
Share on other sites

11 hours ago, owenmaley said:

I'm looking to get into modding and have unity, but I am daunted by all the different tutorials and forum pages. I want to mod 1.2 but don't know where to start.

I'm moderately new to KSP (since 1.1) but have a little JS experience and am learning blender. I just want to create my own personal parts. Could you steer me in the right direction?

If you just want to modify existing parts (or even clone existing parts and change their properties like size, thrust, resources, etc), take a look at Module Manager.  You just need Notepad to make MM configs.

This forum is mainly for plugins (C# code).  For creating parts (blender, unity) you want this forum: http://forum.kerbalspaceprogram.com/index.php?/forum/15-modelling-and-texturing-discussion/

There's a tutorial stickied at the top.

Some modders live-stream their part creation; I know Roverdude does: https://www.twitch.tv/roverdude/videos/past-broadcasts

I personally have no idea how to do 3D models and have no artistic talent anyways :)

Link to comment
Share on other sites

3 hours ago, hab136 said:

If you just want to modify existing parts (or even clone existing parts and change their properties like size, thrust, resources, etc), take a look at Module Manager.  You just need Notepad to make MM configs.

This forum is mainly for plugins (C# code).  For creating parts (blender, unity) you want this forum: http://forum.kerbalspaceprogram.com/index.php?/forum/15-modelling-and-texturing-discussion/

There's a tutorial stickied at the top.

Some modders live-stream their part creation; I know Roverdude does: https://www.twitch.tv/roverdude/videos/past-broadcasts

I personally have no idea how to do 3D models and have no artistic talent anyways :)

Thanks! My current blender creations are quite"Imperfecttm

Link to comment
Share on other sites

What alternatives to OnDestroy() are there for a PartModule to remove its added GameEvents? I ask because I'm making a child class of a stock PartModule to extend its functionality, but the parent class already has an OnDestroy() that isn't marked as virtual so I can't override it. Or does the fact that my child class' OnDestroy() hide the parent class' even interfere with it firing?

Or is it safe to put my destructor in the OnPartDestroyed GameEvent? That seems like a waste of overhead though to check if the destroyed part is this one every time... Thoughts?

Alternately, does anyone know if ModuleCoreHeat does anything important in its OnDestroy()? :P Probably...

Edited by Booots
Link to comment
Share on other sites

OnDestroy() would still be my recommended way of doing this.

If you are really concerned, make base.OnDestroy() the first line of code, that will run the OnDestroy() method from the class you are inheriting from, in this case ModuleCoreHeat, then add whatever code you need to run for your own module.

D.

Link to comment
Share on other sites

2 hours ago, Diazo said:

OnDestroy() would still be my recommended way of doing this.

If you are really concerned, make base.OnDestroy() the first line of code, that will run the OnDestroy() method from the class you are inheriting from, in this case ModuleCoreHeat, then add whatever code you need to run for your own module.

D.

He can't override that because it is not a virtual function (defined in whichever PM he's inheriting from)

The way I'd go would be

part.OnJustAboutToBeDestroyed

Essentially, the game event without you having to do the filtering

Edited by Crzyrndm
Link to comment
Share on other sites

7 hours ago, DMagic said:

You don't have to be able to override it, you can just put "new" in front of the method and call base.OnDestroy inside of it. As long as the base method is public it should work fine.

Thanks!

One more question: FloatCurves... Is there any way to apply a y-scaling factor to them (ie. multiply only the second part of each key) or do I have to create a new FloatCurve every time I want to change any aspect of one?

Link to comment
Share on other sites

The documentation on the wiki doesn't seem to have any instructions on how to develop plugins using a standalone text editor (such as VS Code). Could someone please tell me how to set up a directory with all of the resources I would need for standalone add-on development, and how to use those resources?

Link to comment
Share on other sites

I'm not sure what you mean by standalone?

You require the version of KSP you are developing for installed on the computer as you must establish hard dependencies on .dll files in the KSP data directory.

You do not need Unity itself installed for many plugins, however if you are creating new part models you will need it to import the 3D objects.

D.

Link to comment
Share on other sites

1 hour ago, Sneaky Bstard Sword said:

The documentation on the wiki doesn't seem to have any instructions on how to develop plugins using a standalone text editor (such as VS Code). Could someone please tell me how to set up a directory with all of the resources I would need for standalone add-on development, and how to use those resources?

I'll be blunt but if you require help to set up C# / Omnisharp support in VSCode you should maybe use a full IDE ?

Link to comment
Share on other sites

Sorry to "cross-post", hoping to get a quick answer from another developer.  Is there a way to make ModuleDeployableAntenna less sensitive to the ordering of my meshes?  I have a part that is breaking down if other models with animations are included before mediumDishAntenna.

Link to comment
Share on other sites

1 hour ago, Fwiffo said:

Sorry to "cross-post", hoping to get a quick answer from another developer.  Is there a way to make ModuleDeployableAntenna less sensitive to the ordering of my meshes?  I have a part that is breaking down if other models with animations are included before mediumDishAntenna.

Unfortunately not.  It will only look for the first Animation component in the hierarchy.  There are a bunch of stock modules that control animations and they all do this differently.

You could maybe hack around it if you're winning to write some code...

Edited by blowfish
Link to comment
Share on other sites

Hey all, new to plugins but somewhat seasoned in a variety of languages, just not recently practiced.

I'm trying to incorporate VR support (specifically CV1) to KSP and have several questions.

Primarily, I would like to know if it is possible to implement the native Unity VR support via a plugin, since I have tried manually setting the value of VR.VRSettings.enabled=true; , but it does not take (posting it's value to debug immediately after still reads false). I have tried launching KSP with -vrmode oculus but that doesn't seem to do anything different.

If this is not actually possible, is the only other recourse to use a C# wrapper for OVR? (I tried SharpOVR but had my own set of troubles with that too).

I've tried to modify the project by Vivero at https://github.com/Vivero/Kerbal-VR (not updated to 1.2) which uses open_vr and SteamVR to function, but also only ever worked on OpenGL, to no avail.

 

When remembering that unity now has baked-in VR support I knew that would be the best way to go, but all tutorials talking about enabling vr in unity assume you are the dev with build access, so I don't know how difficult if even possible it is to have it enabled at runtime by a plugin.

Thanks,

Iniq

Link to comment
Share on other sites

I did not test but native VR in the current Unity most likely require the game to be build with the VR player settings option active at build time and I don't think this is the case in KSP.

Link to comment
Share on other sites

Sorry, guys, I didn't read thru all 97 pages to find the answer to my question :( Though, I'm pretty sure nobody has asked it before :)

And here is the question: how to react on OnSave event before any module or game code has persisted anything?

Here is my problem. I connect two vessels into one with a pivot joint (KAS 1.0). It works fine in flight but when it comes to save/load a problem shows up. It looks on save the game stores vessel part positions from their orgPos/orgRot settings, and restores the parts basing on these values. Since the joint is a pivot the real position/rotation differ from the ones stored on the joint creation (part.couple()). As a result, the connected part of the vessel gets rotated to the original angle (the one that was true at the moment of linking). Similar problem happens when time warp is started/stopped but there I can react on OnPartPack and adjust part values via Part.UpdateOrgPosAndRot. With the save event I cannot find a good handler. Obviously, I tried PartModule.OnSave and it didn't work. I need an "uber" OnSave event to have all the values updated.

Link to comment
Share on other sites

1 hour ago, sarbian said:

Did you consider adjusting the rotation instead ? That s you core problem, not saving.

How's it a problem?! There are two vessels, they are somehow positioned and rotated relative to each other. I need them to load exactly like this. And it doesn't happen because game restores relative positions/rotations that were true at the moment of coupling instead of recalling the settings at the moment of saving. Big difference between regular joint and pivot joint is that relative orientation can change in the latter case (see IJointLockState).

Link to comment
Share on other sites

2 hours ago, IgorZ said:

How's it a problem?! There are two vessels, they are somehow positioned and rotated relative to each other. I need them to load exactly like this. And it doesn't happen because game restores relative positions/rotations that were true at the moment of coupling instead of recalling the settings at the moment of saving. Big difference between regular joint and pivot joint is that relative orientation can change in the latter case (see IJointLockState).

I think what he means is that the root cause is the part's orientation being incorrect because it's constantly changing. His suggestion would be to update and correct each part's position and orientation at each tick so that when it comes time to save or pack the part its orientation and position don't need adjusting because they're already up to date. Obviously this comes with the computation overhead of calculating and correcting the orientation of every part in the scene at every tick as opposed to the times when it absolutely needs to be correct.

Does onGameStateSave fire before anything is persisted? If so, you could add something there to go through and fix orientations.

Link to comment
Share on other sites

43 minutes ago, 0111narwhalz said:

I want to get information from my active vessel. I know the property/field I want, but how do I actually get it? I need things like IsControllable and verticalSpeed.

Have a look at Vessel.activeVessel, there are a number of accessible details there. Also have a look at vessel in the Api, linked below. 

https://anatid.github.io/XML-Documentation-for-the-KSP-API/class_vessel.html

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