Hi all, having a great time with adventure creator but I have run into a problem.
I would like to swap the mouse buttons for "Use" and "Look", I want right click to be used for "Use" and the left click action to be "look".
I appreciate I can change the actions I place on an object so that "use" is actually "look" and visa-versa but I would like to hard code it to avoid confusion.
I saw a post that said I can edit the playerInteraction.cs file. I have tried, but I just seem to break the "Look" functionality.
Please could someone tell me which line relate to hotspots only. I don't want to change inventory functionality, I also saw something about cancel action. Without knowing what that does at this stage any advice on whether I need to change that is appreciated.
Thanks
Will
Comments
You could edit the instances of GetMouseState in PlayerInteraction, which is used to determine the current mouse state - however it's recommended to instead use input overrides if you want to remap your controls. This tutorial covers the concept of doing so.
In order to swap the mouse buttons when over a Hotspot, you simply need to create a new delegate for PlayerInput's InputGetMouseButtonDownDelegate, and swap the buttons if over a Hotspot.
This code, placed in a script named "SwapInputs", and on a GameObject in your scene, will do the trick:
using UnityEngine;
using System.Collections;
using AC;
public class SwapInputs : MonoBehaviour
{
private void Start ()
{
KickStarter.playerInput.InputGetMouseButtonDownDelegate = CustomGetMouseButtonDown;
}
private bool CustomGetMouseButtonDown (int mouseButton)
{
if (KickStarter.playerInteraction.GetActiveHotspot () != null)
{
// Mouse is over a Hotspot, so..
if (mouseButton == 0)
{
// Left becomes right
mouseButton = 1;
}
else if (mouseButton == 1)
{
// Right becomes left
mouseButton = 0;
}
}
return Input.GetMouseButtonDown (mouseButton);
}
}