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
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.
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.
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?
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.
thanks
but i get some strange behavior when i rotate the pickup
it's location change according to the rotation
also how to make the rotation work with mouse 0 hold
thanks again
http://pasteall.org/916803/csharp
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?
Try this:
http://pasteall.org/1442362/csharp
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.