I use panning via Camera Drag 2D, but whenever I "grab" the scene to scroll around it the player follows to the position where I grabbed it. I would like the player to stay put while I use panning and move only based on a simple click/tap when the panning is not used. I use the point and click movement method (it is a pnc game).
I think the solution could be that the player walks to a destination only after:
1) mouse up/tap has been released
2) between mouse down/tap down, there was 0 drag detected
Otherwise, only panning would occur.
How could I implement this modification to player movement input?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
*2) between mouse down/tap down AND mouse up/tap release, there was 0 drag detected
You can achieve this with the use of input override delegates - see the Manual's "Remapping inputs" chapter for details.
This might need more tweaking to get working for other devices / account for Menus etc, but something along these lines should do it:
Works great so far, thanks! Will report how it works with the menus and inventory once i get to that bit :-)
So unfortunately it only works when using the mouse. But it doesn't work on mobile while using the touchscreen - which is actually where I will be needing it the most. Can you please help?
This would be the equivalent for touch input:
We can merge them together if successful, but it needs the Input method to remain as Mouse And Keyboard for it to kick in.
It is giving me compiler error CS0034 regarding the operator != not being specific on Vector2 and 3 on this line:
if (button == 0 && Input.touchCount > 0 && Input.GetTouch(0).position != startPosition)
Replace
Vector3
withVector2
.The character does not move or react at all. I tried to set mouse and keyboard and touch screen and the result is still the same.
I tried the script from February 6 on the mobile version while setting mouse and keyboard input. It works nicely, however, I am also using pinch zoom and once I attempt to zoom in, the game goes bonkers and jumps outside of the scene into black. That is a problem, as I need to be able to zoom, but also i want to be able to scroll around the scene without the character running after my finger. Is it even possible to use the pinch zoom when the mouse and key are set as input?
I'll need to be very clear on your exact setup. Can you share the scripts involved, with details on where they're attached / screenshots of your Settings Manager?
Sure. Currently, I am using Cmera2DDrag with this Zoom script attached to it:
Then I am using your ClickUpToMove script attached to an empty object in each scene. When I use the version from 6. Feb, the camera flickers and ultimately flies away from the scene while zooming. When I use the version from Feb 7, the character does not react to clicking and does not move at all.
Lastly, I am using frame flip script on the Player (but I assume that does not affect the issue?) https://adventure-creator.fandom.com/wiki/Frame-flipping_for_Sprites_Unity_Complex_characters
The Feb 7 version references touch-screen input - are you testing on a device, or in the Editor?
My mistake, trying on an Android device now but it is also not good. The character is moving this time, however, panning does not work, when I tap somewhere while the character is moving, it twitches (like the movement command was reset, it does not do that in other instances). Also when I try to zoom in, the camera starts to shiver and then flies away completely outside of the scene into black.
As this needs to also consider the zooming and custom camera motion in your other thread, let's get the latter working first in the Editor with the mouse - and revisit Android once its behaving on a single platform first.
Combined with the other thread, there are now three custom scripts at play. I've updated your other thread - disable PanZoom for now, let's get the other working and we can then add the extra functionality.
Works on Desktop! More in the other thread https://adventurecreator.org/forum/discussion/14517/pinch-zoom-and-panning-on-mobiles#latest