Forum rules - please read before posting.

Hot Switch Between Keyboard/Mouse and Controller

Hi, I've just started using Adventure Creator, it really works great.

I'm trying to create a game that lets the player use keyboard/mouse or controller. Everything's almost working (using the Walking Dead example UI), but I just need to be able to switch between the two control schemes. That control is currently locked away in the Settings menu. And it has to be one or the other.

I read in someone else's post here a problem and the solution given was to go here http://www.adventurecreator.org/scripting-guide/class_a_c_1_1_settings_manager.html and look up the command, then write a Custom Action http://www.adventurecreator.org/tutorials/writing-custom-action

I followed all that as much as I could but, not being a programmer, I couldn't just copy and paste the action I found...

InputMethod AC.SettingsManager.inputMethod = InputMethod.MouseAndKeyboard

It was going to require a little more knowledge. Like exactly where in the ActionTemplate.cs script that line goes?

Comments

  • Welcome to the community, @FractalCore.

    You can read all about custom Actions, and the location of the ActionTemplate script, by following this tutorial.

    To change the movement method to e.g. "Mouse and Keyboard", you'll want to place the following in your Action's Run() function:

    KickStarter.settingsManager.inputMethod = InputMethod.MouseAndKeyboard;

    Going further, you could make a new public InputMethod variable in your Action, so that you can expose/change it in your Action's GUI.  You'd then be able to re-use the same Action for whichever input method you wanted.

    Be mindful, however, that since the Settings Manager is an asset file - any changes you make to it will not be reverted once you exit the game.  Therefore, you'll have to set your desired Input method when your game begins by running this Action in your game's ActionList when start game field, at the top of the Settings Manager.

    I expect you'd want to map this to an Options setting, too.  This tutorial covers the principles involved.
  • Thanks, got it to work with the...

    KickStarter.settingsManager.inputMethod = InputMethod.MouseAndKeyboard;

    placed in the action template. The rest was easy.
  • Hey there, to build on this question - when switching to keyboard controls, is there a way to use the navmesh boundaries as collision? Or do I have to use actual collision cubes?
  • No - NavMeshes and collisions are different objects.
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.