Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smooth camera drag. #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cisar2218
Copy link

  • Camera drag separated from swipe: created OnDragEvent with Vector3 position difference.

  • Events in PlayScreenState reassigned to new OnDragEvent.

  • Not tested on actual mobile device => drag speed value may need adjustments.

  • In future drag speed could be based on zoom.

  • Camera is not clambed to reasonable map radius yet.

- Camera drag separated from swipe: `OnDragEvent` with `Vector3` position difference.
- Events in `PlayScreenState` reassigned to new `OnDragEvent`
Copy link
Member

@darkfriend77 darkfriend77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thx looks good.

I tested it, and found the following behavior, that broke on the PR, interaction with the board should only be possible on the Board screen, ray cast should be blocked by the overlapping UI, parts.

I added a picture to visualize it for a better understanding.

image

@cisar2218
Copy link
Author

cisar2218 commented Mar 29, 2024

Thx for feedback. I added the check that should do the work. However problem is that pointer callback is sometimes resolved after input callback. Meaning the current UI detection is not 100% accurate (at least in my environment).

Current pointer callbacks:

_root.Q("BottomBound").RegisterCallback<PointerEnterEvent>(e => isPointerOverUI = true);
_root.Q("FloatBody").RegisterCallback<PointerEnterEvent>(e => isPointerOverUI = false);

Should I couple the checks to handle input function to remove the issue? Since it's used only for draging and swiping in the code currently. Like so:

case TouchPhase.Moved:
    touchEnd = position;
        if (!isSwiping && /* manual check with new function here: */ isPointerOverUI() && Vector2.Distance(touchStart, touchEnd) >= swipeThreshold)
        {
            ProcessSwipe(touchEnd.x - touchStart.x, touchEnd.y - touchStart.y);
            isSwiping = true;
        }
        break;

@darkfriend77
Copy link
Member

Okay, I tested it. I did the following test.

When you switch from trying to swipe from the board screen to the selection screen and vice versa, the first attempt acts the opposite way as expected. It swipes on the Selection and it blocks on the Board, seems a logic issue. repeating attempts in the same space are then correctly handled.

Recreate the test.

- Try Swipe 3 x in Board
- Try Swipe 3 x in Selection
...

Hope that helps to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants