Profile image

Mod making with multiple inputs

6 ArmouredTrashCan  one month ago

I have been beating my head against the wall with this one. I am trying to create a mod part with multiple input axis and I can not figure out how to reference more than one. Any help would be great.

  • Log in to leave a comment
  • Profile image
    52.0k PlaneFlightX

    I actually had the exact same issue as you!
    Example code:
    Right after the behavior class start:
    // Array of input controllers.
    Jundroo.SimplePlanes.ModTools.Parts.IInputController[] inputs = new Jundroo.SimplePlanes.ModTools.Parts.IInputController[3];
    float input_scaleX;
    float input_scaleY;
    float input_scaleZ;

    In the start void:
    inputs = this.GetComponentsInChildren<Jundroo.SimplePlanes.ModTools.Parts.IInputController>();

    And then just do this._scaleX = inputs[0].Value;

    Hopefully you can understand how it works and can apply it to your own code.

    Pinned one month ago
  • Profile image
    52.0k PlaneFlightX

    @ArmouredTrashCan good to hear

    one month ago
  • Profile image

    @PlaneFlightX I got it sorted. Thank you

    +1 one month ago
  • Profile image
    52.0k PlaneFlightX

    Update, just looked at my code and in the earlier example I sent, I define variables and then set different ones. This new comment fixes that. I also made all the characters show up correctly (for example this:
    "<"
    doesn't turn into this:
    &quot;&lt;&quot;
    )

    Right after the behavior class start:

    Jundroo.SimplePlanes.ModTools.Parts.IInputController[] inputs = new Jundroo.SimplePlanes.ModTools.Parts.IInputController[3];
    private float _scaleX = 0;
    private float _scaleY = 0;
    private float _scaleZ = 0;

    In the start void:

    inputs = this.GetComponentsInChildren<Jundroo.SimplePlanes.ModTools.Parts.IInputController>();

    In the update void, wherever you please:
    this._scaleX = inputs[0].Value;
    this._scaleY = inputs[1].Value;
    this._scaleZ = inputs[2].Value;

    And obviously you can take the basic syntax structure and change it as you need. This code is for three input controllers.

    Also, if you're wondering what stuff like private is, they are keywords in C# but they don't seem to be required for the purpose of scripting part behavior. Some of my variables have them, some don't. My code is also a mix of random stuff I got from other mods and the internet, but it works.

    one month ago
  • Profile image
    52.0k PlaneFlightX

    @ArmouredTrashCan oh, &lt; is <, same with &gt; and >
    It's just how code blocks format it.

    one month ago
  • Profile image

    @PlaneFlightX I am getting an error with &lt; Do I need a library or something to get that phrase to work

    one month ago
  • Profile image

    That looks like it'll work

    one month ago