Jump to content

[Unity] FloatCurve editor 1.0


r4m0n

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:

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

Link to comment
Share on other sites

  • 2 months later...
  • 10 months later...
  • 9 months later...
  • 11 months later...
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.

 

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
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.

Link to comment
Share on other sites

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

 

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

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