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

Drag will compute NaN values if the character teleport to a new position #11

Open
xoyojank opened this issue Dec 7, 2022 · 1 comment

Comments

@xoyojank
Copy link

xoyojank commented Dec 7, 2022

MoveSpeed value will be very very large

@TojiroIwamoto
Copy link

TojiroIwamoto commented Mar 15, 2024

Hi

I don't know if this is appropriate, but we tried to deal with it this way and it stopped being NaN,
The Drag section has a behavior that seems to diverge infinitely when warping or moving at high speed.

You might want to brush up the code more.
We are not looking for strictness, so this was a good enough behavior for us.
It would be great if the person who created SPCR could improve it if possible!,

AnimNode_SPCRJointDynamics.cpp

			if (bUseDrag)
			{
				float MoveSpeed = Displacement.SizeSquared();
				FVector VelNormalize = Displacement.GetSafeNormal();
				//instead of -1 can I make the -1/2??
				FVector DragForce = -1 * ((Point.Drag * MoveSpeed * VelNormalize) / 2);

				Displacement += DragForce;
			}

			if (bUseDrag)
			{
				float MoveSpeed = Displacement.SizeSquared();
				FVector VelNormalize = Displacement.GetSafeNormal();
				//instead of -1 can I make the -1/2??
				FVector DragForce = -1 * ((Point.Drag * MoveSpeed * VelNormalize) * 0.5);

				//Start CUSTOM Not to diverge endlessly.
				if (Displacement.Length() > DragForce.Length())
				{
					Displacement += DragForce;
				}
				else
				{
					if (Displacement.Length() > 0.001f)
					{
						float gainScale = Displacement.Length() / DragForce.Length();
						Displacement += DragForce * gainScale * 0.9999f;
					}
				}
				//Custom End
			}

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