Topic: Getting cInput working with UFE

I'm in the process of getting cInput working in UFE. Will update as I find hurdles and how to jump them.

I was recently successful in getting cInput setup to work in the Character Select screen, but am currently stuck in trying to get it working for the actual game engine. Apparently, the Update() on ControlsScript.cs is where this would have to be done. Presently, there's an array linked to the Unity input config in some way.

So either, we would need to change the array in the foreach loop to be an array of our custom controls, or totally refactor how the foreach is used in the Update() method. I'm leaning to the second option as I'm out of ideas for the first option.

foreach (InputReferences inputRef in inputReferences) {

Share

Thumbs up 0 Thumbs down

Re: Getting cInput working with UFE

I'm actually working on a more universal InputScript that will allow for an easier script approach, but in essence, this is what the loop does:
Inside the loop you will notice lines such as these:

if (Input.GetAxisRaw(inputRef.inputButtonName) > 0) {
Input.GetButton(inputRef.inputButtonName)

These are a direct call to the standard Input Manager from Unity. The loop is basically just browsing through every input registered into the Global Editor - Input Options and checking if any of them were triggered.
Originally, these inputs are set by default into the InputManager file provided with the package, and they can be edited here.

As for cInput, if I'm not mistaken you can simply replace every "Input." under ControlsScript.cs with "cInput.", given that cInput also have methods such as GetButton and GetAxisRaw (If it does not have GetAxisRaw, you can change those to GetAxis).

Now, cInput probably has its own system to name a specific button reference so it can detect which button was pressed. In that case, you will probably also have to edit the input references set on the Input Options so it matches the references under cInput.

In other words, if you have something like cInput.GetButton("buttonA"), you have to make sure that "buttonA" is also listed under the Input Options on UFE.

PS: Im not entirely sure how the methods inside cInput are, but you can still follow a similar pattern if you want to change the input class. any reference to the Input class is inside that loop, and all its string references are inside the Input Options.

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.

3 (edited by MrPonton 2014-04-09 20:33:05)

Re: Getting cInput working with UFE

Hmm, thanks for letting me know. However I tried modifying the Global config's input with similar issues.

I can make it to the Round fight start. However. pushing the new P1HorizontalAxis, P1VerticalAxis, and P2VerticalAxis  does nothing. Pushing P2HorizontalAxis moves the second player left/right, and pushing any new attack button has an error pop up stating:

Couldn't find a key match for P2HorizontalAxis. Is it possible you typed it wrong or forgot to setup your defaults after making changes?
UnityEngine.Debug:LogError(Object)
ControlsScript:Update() (at Assets/UFE/Scripts/ControlsScript.cs:415)

For both the horizontal and vertical of the player who pressed the attack button. Resuming the game instance plays the attack though.

Any thoughts as to what the cause could be?

Edit: Only for P2, if I hit LEFT + DOWN he'll jump forward. RIGHT+DOWN he'll jump right. DOWN he won't do anything. LEFT+UP he'll crouch (forward?). RIGHT+UP he'll crouch (backward?). UP he won't do anything...

Share

Thumbs up Thumbs down

Re: Getting cInput working with UFE

Humm its very hard to tell. I'm not sure exactly how far you got and if you are using cInput at this point.
I also never used cInput so I don't know how you set its key configurations or if it even uses Unity's Input Manager.
That error seems to come from cInput itself and from the looks of it, seems like you need to setup those buttons in there.
Originally, what UFE does is simply detect the Input being pressed that was originally listed in the Input manger.
In other words, this:
http://s11.postimg.org/vq5oc3dab/Input_Manager.jpg

Connects to this:
http://s24.postimg.org/dtgk220ud/Input_Manager_Unity.jpg

So in essence, the foreach loop inside ControlsScript.cs is doing something like this:

if (Input.GetButton("P1Button6")){
..
}

Where P1Button6 is a listed Axis on Unity's Input Manager.

Since you changed Input. to cInput., you'll either have to change how these buttons are referenced on cInput or how they are named under UFE Input Options.

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.

Re: Getting cInput working with UFE

Right,

So I did cInput's set calls in the IntroScript.cs. Once the setters are made then you don't have to set it anymore:

cInput.SetKey("1_Up", Keys.W);
        cInput.SetKey("1_Down", Keys.S);
        cInput.SetKey("1_Left", Keys.A);
        cInput.SetKey("1_Right", Keys.D);
        cInput.SetKey("1_Button1", Keys.T);
        cInput.SetAxis("1_Horizontal", "1_Left", "1_Right");
        cInput.SetAxis("1_Vertical", "1_Up", "1_Down");

So I'd expect changing

Input.GetAxis("P1Button1");


to

cInput.GetAxis("1_Button1"); 

Should work if I change UFE > Global > Input Options > P1Button 1 to 1_Button1.

So far that seems fine, as minus the error with the axis, the buttons are responding as I set them so yeah.

But I think it gets confused when you see

if (inputRef.inputType != InputType.Button && cInput.GetAxisRaw("Horizontal") != 0) {

as the "Horizontal" I'm not sure is established.

Just find it awkward that P2's left/right works fine, that P2's up/down only works when left/right are being pressed as well, and that P1's axes are not doing anything at all. I'd expect P1/P2 to be doing the same thing with the same issues :-/.

Share

Thumbs up Thumbs down

Re: Getting cInput working with UFE

MrPonton wrote:

But I think it gets confused when you see

if (inputRef.inputType != InputType.Button && cInput.GetAxisRaw("Horizontal") != 0) {

as the "Horizontal" I'm not sure is established.

Just find it awkward that P2's left/right works fine, that P2's up/down only works when left/right are being pressed as well, and that P1's axes are not doing anything at all. I'd expect P1/P2 to be doing the same thing with the same issues :-/.


Humm I'm sorry I'm not quite following at this point.
Did you add that line in your code? I don't think I've added any direct Input.GetAxisRaw([string]) on ControlsScript.cs.
I've just made a search here and I don't have any string "Horizontal" originally written on ControlsScript either.
Maybe you changed a few things around before?

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.

Re: Getting cInput working with UFE

Thanks for pointing that out. I'll double-check my changesets to verify. It's possible it was collateral damage with me figuring out the work flow.

Share

Thumbs up Thumbs down

Re: Getting cInput working with UFE

Okay, thankfully my changeset shows that I must have added that bit of code, and correcting all the instances of GetAxisRaw("Horizontal") to inputRef.inputButtonName got the characters to move correctly.

Only issue I'm dealing with now is that when I press an attack button it says it can't find a key match for the player's horizontal and vertical, " Is it possible you typed it wrong or forgot to setup your defaults after making changes?".

If I resume after the exception, the attack motions properly and resumes fine until another attack button is pressed.

Both axes are in the input config, otherwise i couldn't move the characters around.

Trying to debug it I can follow it until the following code will throw the exception upon completing the foreach initiated around 266:

foreach (InputReferences inputRef in inputReferences) {

Share

Thumbs up Thumbs down

Re: Getting cInput working with UFE

Okay, I'm not sure yet if this is a bug in UFE or a bug in cInput.

However, I was able to get the error "fixed" by setting a key with the same name as each axis. What was happening was for some reason the flow would get to cInput's code where it'd be looking for the axis as a key where it'd throw an exception. Yes I've "fixed" it, but sadly I don't think the way I did it actually is correct.

Share

Thumbs up Thumbs down

Re: Getting cInput working with UFE

MrPonton wrote:

Trying to debug it I can follow it until the following code will throw the exception upon completing the foreach initiated around 266:

foreach (InputReferences inputRef in inputReferences) {

I wouldn't trust that debug error hehe. I googled the previous error string (Is it possible you typed it wrong or forgot to setup your defaults after making changes?) and it seems to be a custom error from cInput.

When you set an input as Horizontal Axis or Vertical Axis on Global Editor -> Input Options you are telling the engine to detect those inputs as axis (Input.GetAxisRaw([Input Name]) > 0 and Input.GetAxisRaw([Input Name]) < 0 ) instead of buttons (Input.GetButton([Input Name])).

I got some help from a programmer who is currently working with cInput and he managed to get some neet compatibilities with both cInput and Control Freak (mobile port). I haven't had the chance to check on his development yet, but I think you are heading in the right direction as well.

With any luck I might be able to incorporate those updates into the next version from UFE.

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.

Re: Getting cInput working with UFE

Yeah I have each axis set as an Axis in the Input Options, but in the cInput it's checking for a key called "P1KeyboardHorizontal". It also is properly checking for an axis called "P1KeyboardHorizontal", so it's like expecting this Key to exists when it isn't. :-/

Share

Thumbs up Thumbs down