Download

My Rotators to AxisAngle works with Transform but need Angular Velocity

Hello,

I am reworking some of my motion controller handling to fix some problems and want to use more physics rather than direct transforms. Like this.
The translate movement is already working fine by calculating directional move velocity and applying with a Set Physics Linear Velocity.

But I have problem with the physics based rotation.
I have made a blueprint node to get the rotation difference between rotators and output the result as an AxisAngle. The idea was to feed this into a Set Physics Angular Velocity bp node.

Now the homemade bp node’s axisangle output works perfectly when being fed as a direct rotation transform.
But when I use it for angular velocity it never works no matter what I do. Both directions and speeds of rotations seem really wrong even after tweaking magic numbers.

Would anyone be able to tell me what I am missing?
Why is my axisangle not working for Angular Velocity?

Cheers
Fredrik


FVector UBRTest::RotatorToAxisAngle(FRotator InRotatorNew, FRotator InRotatorOld)
{
	FVector axis;
	float angle;

	FQuat InNewQ(InRotatorNew);
	FQuat InOldQ(InRotatorOld);

	InNewQ.EnforceShortestArcWith(InOldQ);
	InNewQ.ToAxisAndAngle(axis, angle);

	axis.Normalize();

	// was: 180 then 360, now should be same but in radians
	if (angle > PI )
		angle -= 2*PI;

	axis *= angle;  //length of vecor is angle in radians
	
	return axis;
}