Hi, I'm working on a FPS game where there will be combat. Therefore, I'd like the left mouse click to be used to shoot weapons by default, and the E key to handle the AC interactions with the world. How would I go about making such a change?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Could you try this:
I think you could get the wanted behaviour by unchecking "Mouse clicks have default functionality?" in AC Editor -> Settings -> Interface Settings, one under "Input Method:".
And then you go into your Project Settings -> Input Manager, and set up a new Input called "InteractionA" and set the positive Button to "e".
Great, thank you, will try this.
I tried this, but then doing so has the effect that even clicking options on a menu require to press the "E" key (instead of the left mouse button)
The behaviour I'm trying to achieve is this:
1. When in-game, clicking left mouse button fires a weapon. And pressing 'e' interacts with Hotspots etc.
2. When the game is paused or on a menu or in a cut scene, the left mouse button acts as the regular mouse cursor, at which point, left click would behave as a regular left click and interact with the UI.
Thanks in advance for any insights on how to achieve this. Thank you.
Hmm... I had a look at the combat example project. This code looks promising:
I further studied the FP_Crouch script that comes with the downloadable First Person controller for AC. I think I might be able to make a copy of that and then use the above script as an FP_Shoot script
Would this be the right approach?
I've set it up again and i can't recreate the issue that you have.
https://streamable.com/bp2t5u
I have the FPS Player and if i set it up like this it does work how you intended, mouseclicks don't activate the hotspot, only "e" does, and when i press escape or use a Menu, the mouseclicks work how they should.
The "pause game when enabled" option on the affected menu, should automatically pause the game and unlock the mouse.
Chris can probably help out, i wasn't able to get the same problem
Hi Snan, thank you for checking back; I did try it again, but I'm facing the same issue. If I go to the Input Manager and map InteractionA to the "e" key, then in all the menus, I have to press "e" instead of left mouseclick to select a menu item. And mouse clicks don't do anything. Not sure what might be working differently for me, but thank you for trying to help. Let me keep checking.
Meanwhile, @ChrisIceBox please let me know if I'm doing anything wrong.
Did by chance the Mouse Button Interaction somehow get screwed up/replaced in the Input Settings?
Maybe i'm overlooking something. Hope you can get it figured out.
//
I did it in a completely new empty Project, too.
And everything works as intended, that is very confusing.
Hey Snan, I started a new empty unity project, added AC into it, and then unchecked "Mouse clicks have default functionality?" and as expected mouse clicks don't work on the menu nor interact with hotspots.
Then I added InteractionA in Input Manager and mapped it to "e" and now pressing "e" works for both interactions and to select a menu item. But mouse clicks don't work at all in the menus.
Not sure what I'm doing wrong. I will keep trying, thank you for your help.
I found the solution here:
https://www.adventurecreator.org/forum/discussion/9331/button-press-to-pickup-item
It seems another user had the same problem; if he disabled "Mouse clicks have default functionality?" then the menus stopped responding to mouseclicks.
Instead, he changed "Interaction Method" to "Choose Interaction then hotspot" which gives three new input actions for the Input Manager. And you can map custom keys to "use", "examine" etc.
Thank you for the suggestions and help.
Ok, the above method didn't fully work so I finally solved it as follows:
1. Set "Settings > Interface Settings > Interaction Method" to "Custom Script"
2. Keep "Mouse Clicks have Default functionality" as checked (so menus will work)
3. Created the below script for a custom interaction:
This works for me because I'm making a very simple combat based game where there is only one interaction with any hotspot. I needed a very simple solution and this seems to be working so far.