Forum rules - please read before posting.

changing the way interacting work

first of all i want to say that this asset is the best thing i have ever purchased from the asset store
but i have some questions 
i'm working on a 3D first person game
can i change the way i interact with hotspots and draggable 
i want to pick up objects with a left mouse click and to drop it with another left mouse click and if i'm holding an object i can rotate it with a left mouse hold

also if i have two use interactions on the same hotspot can i assign a button for every action
for example if i'm looking at hotspot a left mouse click run the use interaction and space bar run the Talk to interaction

any help will be appreciated
thanks

Comments

  • Welcome to the community, @medo5426.

    i want to pick up objects with a left mouse click and to drop it with another left mouse click and if i'm holding an object i can rotate it with a left mouse hold

    If you're happy with AC's PickUp system aside from the controls, then you should be able to do this by overriding the inputs.  Otherwise, you may need a totally custom system - as given the complexity of the draggable system, there's not much room for flexibility.

    The overriding of inputs is covered in the Manual's "Remapping inputs" chapter, as well as this tutorial.

    The grabbing of PickUp objects is performed whenever the InteractionA input button / left-mouse button is held down.  However, it is possible to define a separate input for this task in the PlayerInput component, which can be found on the GameEngine object in your scene.  When you define a "Drag input override", that becomes the name of the input button to press to keep a PickUp object held.

    Now, any input button or axis can be overridden through delegates - see the above tutorial and Manual chapter.  Because the input is expected to be pressed, you need to override the InputGetButtonDownDelegate so that it returns "True" if an object is held, unless the input is pressed down.

    Try this:
    http://pasteall.org/792125/csharp

    Unfortunately, this also requires a change to the PlayerInput script - one I'll be making in the next release.  This change is a simple function addition - paste this into the PlayerInput.cs script somewhere:

    public bool IsDragObjectHeld ()
    {
        return (dragObject != null);
    }


    (I'll make the same addition to the next update of AC)

    Now, that should at least get discrete clicks to work (once you've set the "Drag input override" to "HoldDraggable" and defined it as "mouse 0" in Unity's Input Manager).  To get it working so that it doesn't respond if the player is holding it down to rotate it is more complicated, but see how you go with that first.

    also if i have two use interactions on the same hotspot can i assign a button for every action
    for example if i'm looking at hotspot a left mouse click run the use interaction and space bar run the Talk to interaction

    This requires setting the Settings Manager's Interaction method to Choose Hotspot Then Interaction, and Select Interactions by to Clicking Menu (as used by the provided 2D Demo).  With these settings, interactions occur by clicking on a Hotspot, and choosing an interaction via icons in a Menu.  The trick here is that Interaction elements in a Menu have an Alternative input button field, which cause the Interaction to behave as though clicked normally when a given input is invoked.  You can try it by loading up the 2D Demo Managers / scene, and entering values into the various Interaction elements in the Interaction menu.  This does, of course, require that the Interaction menu be open - but you can see about making it invisible / hiding it from view once it at least responds to the correct inputs.
  • hi Chris

    thanks for your reply

    i did what you said and now i can hold the object with one mouse click but when i click again it's not releasing the pickup

    can you help me with that?
  • Apologies, @medo5426, there was a mistake.  Try this instead:
    http://pasteall.org/911479/csharp

    Unfortunately, some more minor changes to PlayerInput.cs will again be necessary.

    1) Change all instances of LetGo (false); to:
    LetGo ();

    2) Change all instances of LetGo (true); to:
    LetGo ();

    3) Change the line private void LetGo (bool unlockFPSCamera) to:
    public void LetGo ()

    Again, I'll make those same changes to the next release.
  • that work great
    thanks
    but i get some strange behavior when i rotate the pickup 
    it's location change according to the rotation 
    image

    also how to make the rotation work with mouse 0 hold

    thanks again :)
  • OK - I'll take a look.
  • Since you only need the mouse for all this, it's possible to use Unity's Event system to make this easier.  Try this:

    http://pasteall.org/916803/csharp

  • thanks that helped me a lot

    i changed some things to make it work like i want

    thanks again for your great support
  • I've followed the steps and made use the script that was posted on April 9th, and it seems to work perfectly. However, I need to be able to keep the right click (Mouse 1) functionality neutral while the object is held. I haven't been able to figure out how to modify the code to do this.

    Is there way to make it so that only a click from Mouse 0 drops the object?

  • edited December 2018

    Nice, it appears to work just fine. The script also disables the previous script's left-click-hold rotation, but surprisingly this is also the effect that I prefer; holding another button, like Left Shift, to rotate feels cleaner. Thanks, Chris.

    This style of interaction seems like it could work pretty well as an officially implemented alternative.

    Edit: Actually, I can see why toggle-to-hold may be inelegant for draggable track objects like hinges and doors and drawers. But for common pick-ups it works very well.

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.