Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

When adding Joystick as a child of an element it no longer behaves correctly #9

Open
N-Milinkovic opened this issue Jan 4, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@N-Milinkovic
Copy link

N-Milinkovic commented Jan 4, 2024

Description

When adding Joystick as a child of a Visual Element with the intention of to be a bounding area for the joystick to exist, I've found that the logic does not take into account the joystick rect position and the subsequent mouse position relative to the joystick rect

The Idea being that the joystick would appear only in the highlighted area
image

Environment

  • Unity 2021.3.16f1

Steps to reproduce

This can be reproduced in the sample test document by adding two Visual Elements and setting the Joystick as a child of the second with any alignment
image
better-joystick-example

Expected behaviour

Joystick should remain within the bounds relative to the parent

Actual behaviour

Joystick moves itself outside of the container

Possible solutions

By considering position of the parent element when determining the bounding box and then the mouse position relative to the bounding rectangle, we can accurately check and set whether the mouse pointer is within the range of the rectangle and ensure that the inner joystick's bounds are contained within the joystick element.

better-joystick-circle-fix
better-joystick-rect-fix

@uurha
Copy link
Collaborator

uurha commented Jan 5, 2024

Thanks for pointing to this issue, I'll proceed to fix it and notify you!

@uurha uurha self-assigned this Jan 5, 2024
@uurha uurha added the bug Something isn't working label Jan 5, 2024
@N-Milinkovic
Copy link
Author

I was too tired at the time to set up the fork with my working solution at the time of writing the issue, I've just done that if you'd like to see the changes I had applied to get it to work

@uurha
Copy link
Collaborator

uurha commented Jan 5, 2024

I was too tired at the time to set up the fork with my working solution at the time of writing the issue, I've just done that if you'd like to see the changes I had applied to get it to work

Sure, make a pull request, I appreciate your help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants