r4m0n

[Unity] FloatCurve editor 1.0

Recommended Posts

This is a small utility that uses the Unity Editor's AnimationCurve edition interface to edit FloatCurve values for use in KSP PartModules (Engine efficiency curves, for example).

KSPCurveEditor.png

How to use:

  • Download this unitypackage
  • Create a new Unity project or use an old one
  • Go to Assets -> Import Package -> Custom Package... and select the file
  • Import all the contents (it's a single file)
  • A new KSP menu will appear (if you already don't have it) after you click anywhere in the menu bar, go to it and select the Curve Editor
  • ???
  • Profit!

You can edit the information in any of the areas (Unity editor, text boxes or text area), and the others will update. Whenever you are done, just copy the contents of the text area to your part.cfg file. You can also paste a copy of your curve from a part.cfg to start editing.

Let me know of any problems or suggestions for improvement.

And above all, have fun :wink:

Share this post


Link to post
Share on other sites

Sweet. Would it be possible to add a feature so that it can load the thrust curves (or whatever they are called) from existing engine parts? Like, say I wanted it to show the curves of the Mainsail, so I'd like to pick the Mainsail from a list of all engines in my game.

Edit: Whoops. Looks like it is not an in-game plugin. But nonetheless, perhaps my feature can be added in some way regardless.

Share this post


Link to post
Share on other sites

Hey r4m0n, can you make it use arbitrary key names, so we can copypasta direct to-from FX group curves?

Share this post


Link to post
Share on other sites
33 minutes ago, BlueNightfury00786 said:

So do I install Unity then put this in or? I don't quite understand.

 

Yes you need Unity for this to work.

Share this post


Link to post
Share on other sites
On 3/21/2017 at 5:57 PM, martinezfg11 said:

Yes you need Unity for this to work.

Kinda figured it out by now, I still don't know what a Curve does. Like how do I make a Efficient Engine? tweaking fuel consumption doesn't do anything and I don't understand the "Atmosphereic" Curve on engines too much.

 

Share this post


Link to post
Share on other sites

Figured out that if your only intention is to smooth your FloatCurve, you can achieve that by convert it to an AnimationCurve and then call SmoothTangents on all points.

 

Edited by FreeThinker

Share this post


Link to post
Share on other sites
On 6/22/2018 at 4:37 AM, FreeThinker said:

Figured out that if your only intention is to smooth your FloatCurve, you can achieve that by convert it to an AnimationCurve and then call SmoothTangents on all points.

 

I know this is old, but would appreciate a bit more info on how to smooth a floatcurve.

Share this post


Link to post
Share on other sites
Posted (edited)
6 hours ago, linuxgurugamer said:

I know this is old, but would appreciate a bit more info on how to smooth a floatcurve.

Here is a little code example:

            var floatCurve = new FloatCurve();
            floatCurve.Add(500, 0 / 255f);
            floatCurve.Add(800, 100 / 255f);
            floatCurve.Add(1000, 200 / 255f);

            for (int i = 0; i < floatCurve.Curve.length; i++)
            {
                floatCurve.Curve.SmoothTangents(i, 0);
            }                                              
                                                                

 

Edited by FreeThinker

Share this post


Link to post
Share on other sites
2 hours ago, FreeThinker said:

Here is a little code example:


            var floatCurve = new FloatCurve();
            floatCurve.Add(500, 0 / 255f);
            floatCurve.Add(800, 100 / 255f);
            floatCurve.Add(1000, 200 / 255f);

            for (int i = 0; i < floatCurve.Curve.length; i++)
            {
                floatCurve.Curve.SmoothTangents(i, 0);
            }                                              
                                                                

 

Thank you.  I was thinking of doing this in Unity, not in code.  But this will do the job for me.

 

Share this post


Link to post
Share on other sites

@linuxgurugamer using this r4mon's curve editor - click on the "Click to edit ->" in the upper let corner and the graph appears. Left click on a key in the graph and two handles appear that you can manipulate. Right click on the key and you have a popup menu to change how the handles act among other things. Looks like it defaults to a smooth transition but select "Broken" (with right click) and the handles on either side move independently.

Share this post


Link to post
Share on other sites

I actually ended up implementing the tangent smoothing and a number of other improvements to Sarbian’s mod, he just released a new version with my changes

 

Share this post


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.