Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

First Person Game - Using Mouse and Keyboard Or Controller

Hello!

I'm working on a game that is in first person and has interaction menus for hotspots.

Now, I want the player to be able to either use a mouse and keyboard OR a controller (xbox or ps) to control the movement and interact with hotspots.

I had a difficult time understanding the documentation on this (probably my fault) - I tried to set up the Settings to say "First Person Movement" and then "Keyboard or Controller" and created the movement inputs as described in a few of the topics I found here after searching. Here are my issues:

1) The movement is jerky for mouse and controller
2) I still can't use the controller to navigate menus, pause, or interact with hotspots
3) It seems I can only choose mouse inputs or controller inputs when setting them up...is this true? Ideally the player should be able to pick up a controller while playing and the game registers the controller and switches to that for input.

Thank you in advance.

Comments

  • Welcome to the community, @secondstar.

    The movement is jerky for mouse and controller

    Which kind of movement, free-aiming? The Free-aim acceleration field in the Settings Manager can be used to smooth things out, though this can also be disabled by setting it to zero.

    You may also need to play around with Unity's input settings themselves - that is, the "CursorHorizontal" and "CursorVertical" inputs you've defined in the Input Manager. Things like "Gravity", "Snap" etc all have an impact on the responsiveness.

    Is mouse movement better when Input method is set to Mouse And Keyboard? I'd recommend finding the settings that work for either control style separately. Don't worry about merging the two just yet - work out what settings are best for mouse input, and what settings are best for controller input. See my comments below about merging the two once things are working for both independently.

    I still can't use the controller to navigate menus, pause, or interact with hotspots

    In order to navigate a menu with a controller, you must use Keyboard Or Controller input, and you must also tell AC which element to first select when the menu is turned on. This can be done within the Menu's properties (i.e. Auto-select first visible element?) or through the use of the Menu: Select element Action in the Menu's "ActionList when turn on".

    By default, only menus that pause the game are directly navigable - but you can use the Engine: Manage systems Action to enable/disable direct navigation of gameplay menus. See the Manual's "Navigating menus directly" chapter for more on this topic.

    It seems I can only choose mouse inputs or controller inputs when setting them up...is this true?

    While you can feasibly rely on Keyboard Or Controller input for mouse as well - CursorHorizontal etc can be set up to accept mouse input - I recommend to rely on the dedicated "Mouse And Keyboard" input option for mouse control.

    However, it is possible to change your input method - and any Manager field, in fact - at runtime through script. Right-click on the Input method field label - you'll get the following API reference to it, which you can use to switch between the two options at any time:

    AC.KickStarter.settingsManager.inputMethod
    

    What you could potentially do is have a background script that essentially detects mouse or controller input, and dynamically switches between the two input methods - along with any other settings you made need changing - accordingly.

  • edited June 12

    Thanks for the response @ChrisIceBox !

    I was able to get it mostly working for the controller (thank you!)- but yeah can't seem to do a smooth switch between the two so sounds like I would have to implement a background script as you suggested because yes, the Mouse and Keyboard setting has MUCH smoother free aiming for the mouse controls.

    I will play around with the Gravity, Snap, etc. settings, though if there are commonly used values other than what I see in the tutorials I'd be grateful.

    Regarding the controller though - The left thumbstick works fine for horizontal movement. But it seems I can only choose one axis for the CursorVertical to use...and I want to allow the player to do free aiming with their right thumbstick similar to how an FPS would. Is there a good way to do this?

  • If you rely on Unity UI for your Menus, then you can define exactly which axes are used to directly navigate them in your Event System. By default, these are "Horizontal" and "Vertical". Unless you supply a custom Event System prefab in the Menu Manager, AC will auto-generate one at runtime.

    Create a new EventSystem via the top toolbar, and replace the Standalone Input Module component with AC's Optional Mouse Input Module. Change the Horizontal / Vertical axes to whatever you like (e.g. "MenuVertical", which you then define in the Input Manager). Then make this a prefab, and assign said prefab into the Menu Manager's Event System prefab field.

  • I am actually using AC's UI...does this make a difference in your suggestion?

    I realize after re-reading my previous post that I wasn't very clear. Apologies!

    The issue I am seeing is that I can only use the right thumbstick to pitch the player's view up and down (Axis 4). I cannot use it to do free aim camera view while using the left thumbstick to actually provide all movement, like an FPS.

  • As in, you can't free-aim horizontally?

    The right thumbstick has two axes. If Axis 4 is up/down, then presumably left/right is Axis 3. Map this to CursorHorizontal - that's the input used to turn horizontally when free-aiming.

  • Got it! It works! Thank you SO much @ChrisIceBox :smiley:

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.
Do NOT follow this link or you will be banned from the site!