Forum rules - please read before posting.

Can I drag objects using right click instead of left?

If so, how do I?

Comments

  • I would also like to use right click for other interactions like clicking hotspots and so on. 
  • The functions performed with a left-click / hold can also be achieved by pressing an Input button with the name InteractionA.  Similarly, a right-click can also be achieved with InteractionB - see the list of available inputs in the Settings Manager.

    You can create a new Input named InteractionA, map it to the button "mouse 0" and it'll cause right-clicks to serve as left.

    However, there is the additional issue of the left-click still working as it should - and right-clicks will also perform their original purpose.  You can override these, however, by creating overrides.

    This tutorial covers the principle of creating functions that override the ones that AC uses to detect input.  You'll want to write a simple script that assigns an empty function to the two mouse delegates: InputGetMouseButtonDelegate and InputGetMouseButtonDownDelegate.

    This script should do it for you - create a new C# script called RemoveMouseInputs and add it to a gameobject in your scene.  It will remove the normal use of the mouse buttons - but an InteractionA input mapped to the mouse button will still work.
  • Will this way still make me able to walk with left mouse as I use right click for interactions? 
  • sorry for the dumb question. Just want to be 100% sure
  • I have tried what you said but Im quiet confused here. In order for me to understand what I have to do, I think I need a more basic explanation. 

    I added the two scripts to an empty gameobject in my scene, added a custom input called InteractionA mapped it to mouse 0 and now nothing works. I guess the scripts are overwriting all the basic inputs and now I have to manually add them all?
  • Only the one script should have been added - the link to the tutorial was meant to give you an understanding into the principles behind what we're doing, not to use directly in your own game.

    The script I wrote for you merely removes default mouse functionality altogether - meaning you can only trigger movement and interactions using the InteractionA input.  Be sure to define that input in your Input Manager.

    I took your saying "and so on" to mean you wanted all left-clicks to be replaced with right-clicks, which is what the method I explained above will do.

    It may be that - if you want to have some uses of the left-click changed to right-click, but not all - you have to edit AC's scripts.  The PlayerMovement, PlayerInteracton and PlayerMenus scripts all check for MouseState.SingleClick (left click) - search for this in the scripts.  You can replace this with MouseState.RightClick whenever you want a right-click to work instead.

    The main issue takes us back to the original issue of dragging objects with a right-click.  AC's drag system only works with a left-click-and-hold, which is why the only way to get a right-click would be to disable mouse input and rely on InteractionA instead (my first post).  To get a mix of e.g. left-click movement, right-click interactions, you'll need to swap your mouse buttons around - so that a InteractionB press results in a left-click.  Do this by defining an input named InteractionB and map it to "mouse 0" - again, after adding the previous script.

    You can then go about replacing the MouseState.SingleClick occurences with MouseState.RightClick wherever you need to.  But now, RightClick will actually be left-clicks in your game - so you'll probably only want to do this in PlayerMovement only.

    I appreciate it's confusing, but it's a complex question!
  • Okay I see. Thanks for a more in-depth explaination
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.