libra34567 Posted November 19, 2016 Share Posted November 19, 2016 So i wrote this radial Menu controlled by the trackpad on the left-hand wand. It determine which button to magnify by my fingers position on trackpad. The Weird movement can be seen .Here i attacked my code related to this problem, the code for left wand. SteamVR_TrackedObject obj; //The wandpublic GameObject buttonHolder; //All the buttons will be children of this objectpublic bool buttonEnabled;void Awake() { obj = GetComponent<SteamVR_TrackedObject>(); //this will be left hand controller}void Update() { var device = SteamVR_Controller.Input((int)obj.index); //if touchpad touched if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad)) { if (buttonEnabled) //if radial menu is open { //touchPadAngle: Get the angle between touch coord and X-axis Vector2 touchedCoord = device.GetAxis(EVRButtonId.k_EButton_Axis0); //what is this line each variable float touchPadAngle = VectorAngle(new Vector2(1, 0), touchedCoord); //(1, 0) is X-axis // ------------------- Find closest button ------------------------ //Description: The process will be done by calculating the angle between button_Vector2 and X-axis (button_V2_to_10) // And then find the button with the closest angler difference with (touchPadAngle). float minAngle = float.PositiveInfinity; Transform minButton = transform; //Temperatry assign wand tranform to it. float pad_N_button_Angle = 0.0f; //Angle between touchPadAngle and buttonAngle. Vector2 button_V2_to_10; float button_Angle; foreach (Transform bt in buttonHolder.transform) { button_V2_to_10 = new Vector2(transform.position.x, transform.position.z) - new Vector2(bt.position.x, bt.position.z); button_Angle = VectorAngle(new Vector2(1, 0), button_V2_to_10); pad_N_button_Angle = Mathf.Abs(button_Angle - touchPadAngle); //Both buttonAngle and touchPadAngle range from -180 to 180, avoid Abs(170 - (-170)) = 340 pad_N_button_Angle = (pad_N_button_Angle > 180) ? Mathf.Abs(pad_N_button_Angle - 360) : pad_N_button_Angle; if (pad_N_button_Angle < minAngle) { minButton = bt; minAngle = pad_N_button_Angle; } } //Magnify the closest button foreach (Transform bt in buttonHolder.transform) { GameObject btGO = bt.gameObject; if (!btGO.GetComponentInChildren<ButtomHandler>().onHover && bt == minButton) { //Magnify } else if (bt != minButton && btGO.GetComponentInChildren<ButtomHandler>().onHover) { //minify } } } else { activateButtonMenu(); } } I'm quite stucked here, Any help would really be appreciated Link to comment Share on other sites More sharing options...
dario Posted December 5, 2016 Share Posted December 5, 2016 Have you tried on a non radial menu (try horizontally or vertically only) - to confirm if it's not the VectorAngle in one axis calculation that's causing this? Link to comment Share on other sites More sharing options...
bakuryu06 Posted April 5, 2018 Share Posted April 5, 2018 Are you able to share how you fixed this issue? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.