better-joystick icon indicating copy to clipboard operation
better-joystick copied to clipboard

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

Open N-Milinkovic opened this issue 1 year ago • 3 comments

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

N-Milinkovic avatar Jan 04 '24 15:01 N-Milinkovic