Forum rules - please read before posting.

First person mode inputs

edited September 2014 in Technical Q&A
While using first person movement and the mouse and keyboard input method, I am trying to allow for multiple input methods for the same functions.

1) CursorHorizontal/Vertical:

I have these axes types set to mouse movement, as per the default, but I would also like these functions to be performed by keyboard keys. For instance, the q and e keys should turn the player left and right. In Unity, the axis "type" seems to be a single possible choice for each axis, so I cannot add in an alternative button, as the type is only set to mouse movement. I've also tried to create another set of CursorHorizontal/Vertical axes, but these do not appear to function at all. 

Any idea on how to map the cursor movement to mouse movement and also a key press?

2) InteractionA/B

It is my understanding that these axes are only available in the keyboard or controller input mode, and I tried mapping the space button to an InteractionA axis in mouse and keyboard input mode, but it didn't seem to function. 

Any idea on how to get these axes to function on a mouse click in addition to a key click in mouse and keyboard input mode?


Also, minor related problem: 

3) I am trying to allow the inventory menu to open when clicking the appropriate gui button, but also when pressing the i key. I set up a cutscene which loops on itself in the background with the Input: Check action, and I've tried both the button and axis check types. When I try the button check type, I get an error: "UnityException: Input Button i is not setup." I then tried to set up an "i" axis, with the i key for the positive, but the same problem arose.

I then tried the axis check type, and created an axis called "Inventory" with the i key for positive, and once again, this fails to function. 

Any idea why I'm having so much trouble with the input manager?


Thanks as always for the help!

Comments

  • The mouse will still work if you've got Keyboard Or Controller mode, provided you've got CursorHorizontal / Vertical defined in your Input Manager, though you may have to tweak your Input settings.

    If you want multiple control schemes, however, better to have the "Input method" setting actually change mid-game.  The code to change this would be:

    AdvGame.GetReferences ().settingsManager.inputMethod = InputMethod.KeyboardOrController;

    But I'll add this to the Engine: Manage systems Action if that would be useful.  Either way, you'd want to create a new Global Variable that determines which Input mode to use (try an Integer), and set Link to to Options Data.  You could then create an Options menu (e.g. a Toggle) that affects this Variable's value, and an ActionList that runs when it's closed would then set the appropriate Input method.
  • Okay I see how it works now (besides the i key still not functioning properly but I might just set that up with playmaker).

    One final question- I see that cursorhorizontal/cursorvertical moves the camera only when the cursor is locked to the center. If the cursor is unlocked, it just moves the cursor (which, after all, makes perfect sense).

    However, without using playmaker, is there a reasonable way to set up rotation of the playerprefab when the cursor is unlocked? So that even when the cursor is unlocked, pressing buttons (q and e, as I've designated) will turn the player left and right without moving the cursor? 

    If not, I guess I can set something up easily enough with playmaker, but I find AC's interface much more straightforward for doing these types of things.

    Thanks again!
  • A simple modification of the PlayerInput script should do this for you.  Look for the occurences of:

    freeAim = Vector2.zero;

    within it.  There should be three.  In Keyboard Or Controller mode, you'll want the second one.  Just change it to read in your custom Input instead.  There should be a similar line you can use for reference just above it, which is used when the cursor is locked.
  • edited September 2014
    Excellent! That works perfectly, thanks! 

    Edit:

    Ah- this also makes mouse movement rotate the camera as well when the cursor is unlocked. I want to find a way to move the camera without moving the mouse, while at the same time moving the mouse without moving the camera.

    Looks like I'll have to turn to playmaker for this- it shouldn't be too hard to attach some script to the player prefab which rotates the whole object when pressing a certain key. Thanks anyway for the help though!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.