Radial Menu and Controller Input
Hi, I'm using the right analog stick to control a radial menu. It gives me the correct angle, but when the stick is released it occasionally will return an angle approximately opposite of what it just was and rounded to the nearest quarter so 90, 270, 280, 0. I have the deadzones set to 0.2 on the analog stick, but I cant seem to get rid of the problem. I tried turning up the deadzones but that didn't help either.
void Update()
{
if (Input.GetAxis("LeftTrigger") > 0)
{
menu.SetActive(true);
TimeController.radialTime();
control.x = Input.GetAxis("Horizontal2");
control.y = Input.GetAxis("Vertical2");
Vector2 norm = control.normalized;
if (norm != Vector2.zero)
{
float angle = Mathf.Atan2(norm.y, -norm.x) / Mathf.PI;
angle *= 180;
angle += 90f;
if (angle < 0)
{
angle += 360;
}
if(angle < 25.7 || angle > 334.3)
{
selection = 1;
}
else if(25.7 < angle && angle < 77.1)
{
selection = 7;
}
else if(77.1 < angle && angle < 128.5)
{
selection = 6;
}
else if(128.5 < angle && angle < 180)
{
selection = 5;
}
else if(180 < angle && angle < 231.4)
{
selection = 4;
}
else if(231.4 < angle && angle < 282.8)
{
selection = 3;
}
else if(282.8 < angle && angle < 334.3)
{
selection = 2;
}
Debug.Log(angle);
wasActive = true;
}
}
else
{
if(wasActive)
{
player.setMode(selection);
wasActive = false;
}
menu.SetActive(false);
TimeController.normalTime();
}
}
Answer by catman73atgaming · Mar 22 at 08:21 PM
Sorry to necro but did you ever figure this out @Maxxus220? Im having the same exact issue
It's been a while, but I looked back at what I did and it looks like I just handled the deadzone manually. So, something like if (control.magnitude > deadzone)
where deadzone is just a float. Hope that helps!
Your answer
Follow this Question
Related Questions
How to make pie menu options interact to OnMouseDown? 0 Answers
Joystick Axis not recognized when deployed to WebGL 1 Answer
XInput D-Pad and Triggers not working 0 Answers
Various questions, need help please. 0 Answers
Help needed with menu navigation. 0 Answers