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

mouse does not detect where the radial is located. #2

Open
BasHamer opened this issue Apr 24, 2024 · 3 comments
Open

mouse does not detect where the radial is located. #2

BasHamer opened this issue Apr 24, 2024 · 3 comments

Comments

@BasHamer
Copy link

so I have two radial controls. one for each thumbstick

For mouse and keyboard the right one will be controlled by mouse and the left one by WASD.

My main issue is that the location that the control is and the location where the mouse is reacting to the control are pretty much on opposite sides of the screen.

non standard interactions would be that I access the selection property via

UpperBuild.Set("selection", state);
UpperBuild.Get("selection");

my settings are as follows.

image

image

video of the issue

https://youtu.be/odisjD-61VE

@BasHamer
Copy link
Author

BasHamer commented Apr 24, 2024

ended up ignoring the mouse code and used my mapping from the controller code

public int GetWagonRadialControlState(Vector2 globalPosition, Vector2 size)
        {
            var h = Input.GetAxis("BuildRight", "BuildLeft");
            var v = Input.GetAxis("BuildDown", "BuildUp");
            if (Input.GetConnectedJoypads().Count > 0 &&(Math.Abs(h) + Math.Abs(v)) < .7)
                return -2;
            var vec = new Vector2(h, v);
            if (Input.GetConnectedJoypads().Count == 0)
                vec =(globalPosition + size / 2) - GetViewport().GetMousePosition();
            var angle = vec.Angle()+2*MathF.PI;
            if (angle > MathF.PI * 2)
                angle -= MathF.PI * 2;
            float segment = (MathF.PI / 180f) * 45f;
            angle -= segment / 2;
            return (16-(int)(angle / segment)-4)%8;
        }

my radial is hardcoded to 8 options and my radial is offset from default. This code probably won't work out of the box for you.

@diklor
Copy link
Owner

diklor commented Apr 25, 2024

Thank you. I don’t know why offset position doesn’t work. You can try scripting the _input function somewhere which will enable the first circle and disable the second if the mouse x position is less than half the screen width and vice versa.

And with the selection for the controller, you can somehow play around with the selection and radial.get_children() like if pressed forward then radial.selection = wrapi(radial,selection, radial.get_child_count(), 0) (obviously)
However, I didn’t count on controllers, maybe I’ll think about it later :(

@BasHamer
Copy link
Author

It's working :) so good enough for me at the moment. happy to share code or answer questions if there is a V2.

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

No branches or pull requests

2 participants