Git Product home page Git Product logo

Comments (4)

dabeschte avatar dabeschte commented on May 26, 2024 1

Hi! Thanks for the great analysis. That is indeed a bug which I simply did not find, probably since I did not allow the shoulders to move backwards. Does removing the "-" sign resolve the issue? I'd be happy to merge a pull request :)

from vrarmik.

sclark39 avatar sclark39 commented on May 26, 2024

Yes I think it would, but I don't have a way to test it. Just saw the issue while I was reading and wanted to make sure to mention it!

If it were me I'd probably rewrite this section to unify the if statements with something along the lines of:

float forwardDistanceRatio = Vector3.Dot(handShoulderOffset, shoulder.transform.forward) / armLength;
float upwardDistanceRatio = Vector3.Dot(handShoulderOffset, shoulder.transform.up) / armLength;

( float distanceRatioThreshold, float shoulderRotationMultiplier ) = 
	( 0 < forwardDistanceRatio 
		? ( 0.5f, distinctShoulderRotationMultiplier )
		: ( 0.08f, distinctShoulderRotationMultiplier * 10.0f ) );

forwardDistanceRatio = 
	Mathf.Sign(forwardDistanceRatio) *
	Mathf.Max(0.0f, Mathf.Abs(forwardDistanceRatio) - distanceRatioThreshold );

targetAngle.y = 
	Mathf.Clamp(
		forwardDistanceRatio * shoulderRotationMultiplier, 
		-distinctShoulderRotationLimitBackward, distinctShoulderRotationLimitForward);

But that's more than just a simple bug fix, and I'm not 100% sure if that is correct C# syntax or not!

from vrarmik.

sclark39 avatar sclark39 commented on May 26, 2024

I actually ended up writing this section totally differently in my port. I decided to just scale the distance ratio into [0,1] based on a threshold range for each direction, apply a EaseInOutSine to the resulting alpha to make it feel more organic, and then multiply it by the maximum rotation in whatever direction it's supposed to be going. A bit easier to tune for my purposes.

from vrarmik.

dabeschte avatar dabeschte commented on May 26, 2024

Thanks for your contribution.
I agree that EaseInOut would make it more organic. I hope I will be able to try these changes on a VR headset in the near future and to update the repository. Unfortunately, this project is not actively maintained and I am not developing in VR/Unity anymore.

from vrarmik.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.