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

Steering wheel not working with two hands #107

Open
CircusCharlie24 opened this issue Apr 1, 2023 · 7 comments
Open

Steering wheel not working with two hands #107

CircusCharlie24 opened this issue Apr 1, 2023 · 7 comments

Comments

@CircusCharlie24
Copy link

Can we make the steering wheel work with two hands?

@shaowei1983
Copy link

I also found, waiting for the official response

@Shivaprasad0703
Copy link

even I"m looking for the same thing. "steering"

@Austinstonecold
Copy link

I have made a fix for this. The new code allows for two hand steering, with both hands affecting the steering at the same time, and fairly realistically. May have a few bugs or odd bits. Also sets the steering back to .5 when not grabbing the wheel.

https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples/blob/76e449f15089b0667c2d7dd0ba274c1714e709a9/Assets/XRI_Examples/UI_3D/Scripts/XRKnob.cs

@CircusCharlie24
Copy link
Author

I have made a fix for this. The new code allows for two hand steering, with both hands affecting the steering at the same time, and fairly realistically. May have a few bugs or odd bits. Also sets the steering back to .5 when not grabbing the wheel.

https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples/blob/76e449f15089b0667c2d7dd0ba274c1714e709a9/Assets/XRI_Examples/UI_3D/Scripts/XRKnob.cs

That is just amazing, thank you so much for fixing it. There is one more issue in the steering wheel, when the motion is clamped and you move your hand around the circumference of the wheel after the max/min value has been reached, it still keeps adding the values, although the wheel doesn't move but you still have to cover that distance in reverse in order for the wheel to start rotating again. If it would be possible for you, would you be able to look into this one as well? Sorry for asking more from you.

@Austinstonecold
Copy link

Austinstonecold commented Apr 12, 2024

I have made a fix for this. The new code allows for two hand steering, with both hands affecting the steering at the same time, and fairly realistically. May have a few bugs or odd bits. Also sets the steering back to .5 when not grabbing the wheel.
https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples/blob/76e449f15089b0667c2d7dd0ba274c1714e709a9/Assets/XRI_Examples/UI_3D/Scripts/XRKnob.cs

That is just amazing, thank you so much for fixing it. There is one more issue in the steering wheel, when the motion is clamped and you move your hand around the circumference of the wheel after the max/min value has been reached, it still keeps adding the values, although the wheel doesn't move but you still have to cover that distance in reverse in order for the wheel to start rotating again. If it would be possible for you, would you be able to look into this one as well? Sorry for asking more from you.

Yes I will do that. I am currently trying to fix two other bugs. Thank you for pointing this one out, as I never noticed. I will let you know when I fix the bugs.

Edit: That isn't actually a bug. I added a Dubug.Log to a part of the script, and the value doesn't actually go below 0 or above 1. The thing you are talking about, I'm guessing is when you go past, you have to go back to the value you clamped to for it to move back down. That is intended, as it would disorient players if it immediately went back.
If you want to see it yourself, go to the SetValue method, and add Debug.Log(value); under the if(m_ClampedMotion). Hope this helps!

@CircusCharlie24
Copy link
Author

I have made a fix for this. The new code allows for two hand steering, with both hands affecting the steering at the same time, and fairly realistically. May have a few bugs or odd bits. Also sets the steering back to .5 when not grabbing the wheel.
https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples/blob/76e449f15089b0667c2d7dd0ba274c1714e709a9/Assets/XRI_Examples/UI_3D/Scripts/XRKnob.cs

That is just amazing, thank you so much for fixing it. There is one more issue in the steering wheel, when the motion is clamped and you move your hand around the circumference of the wheel after the max/min value has been reached, it still keeps adding the values, although the wheel doesn't move but you still have to cover that distance in reverse in order for the wheel to start rotating again. If it would be possible for you, would you be able to look into this one as well? Sorry for asking more from you.

Yes I will do that. I am currently trying to fix two other bugs. Thank you for pointing this one out, as I never noticed. I will let you know when I fix the bugs.

Thanks a lot.

@Austinstonecold
Copy link

I have made a fix for this. The new code allows for two hand steering, with both hands affecting the steering at the same time, and fairly realistically. May have a few bugs or odd bits. Also sets the steering back to .5 when not grabbing the wheel.
https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples/blob/76e449f15089b0667c2d7dd0ba274c1714e709a9/Assets/XRI_Examples/UI_3D/Scripts/XRKnob.cs

That is just amazing, thank you so much for fixing it. There is one more issue in the steering wheel, when the motion is clamped and you move your hand around the circumference of the wheel after the max/min value has been reached, it still keeps adding the values, although the wheel doesn't move but you still have to cover that distance in reverse in order for the wheel to start rotating again. If it would be possible for you, would you be able to look into this one as well? Sorry for asking more from you.

Yes I will do that. I am currently trying to fix two other bugs. Thank you for pointing this one out, as I never noticed. I will let you know when I fix the bugs.

Thanks a lot.

I fixed the release bug! It literally took months, just to realize how to fix it with like 30 lines of code.

This is all you have to update. Paste it over the StartGrab to EndGrab part.

void EndGrab(SelectExitEventArgs args)
{
m_Interactors.Remove(args.interactorObject);

        // Update the base rotation and angles to prevent jumping when one hand releases
        if (m_Interactors.Count == 1)
        {
            UpdateBaseRotationForSingleHand();
        }
    }

    void UpdateBaseRotationForSingleHand()
    {
        if (m_Interactors.Count == 1)
        {
            var interactorTransform = m_Interactors[0].GetAttachTransform(this);
    
            var localOffset = transform.InverseTransformVector(interactorTransform.position - m_Handle.position);
            localOffset.y = 0.0f;
            localOffset.Normalize();

            m_PositionAngles.SetBaseFromVector(localOffset);

            var localForward = transform.InverseTransformDirection(interactorTransform.forward);
            localForward.y = 0.0f;
            localForward.Normalize();

            m_ForwardVectorAngles.SetBaseFromVector(localForward);

            var localUp = transform.InverseTransformDirection(interactorTransform.up);
            localUp.y = 0.0f;
            localUp.Normalize();

            m_UpVectorAngles.SetBaseFromVector(localUp);
        }
    }
    
    Hope this helps!

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

4 participants