Is there a simple way to get the current angular velocity of a pawn?
As far as I know, there isn’t an API call to do this. So the way I implemented this was, at every tick I cached the current rotation. Using (current_rotation - previous_rotation) / DeltaSeconds … will give the necessary angular velocity.
So the pseudo code would look something like this
class AMyActor :: public AActor
{
private:
FRotator mPrevRot;
BeginPlay()
{
mPrevRot = GetActorRotation();
}
Tick(float DeltaSeconds)
{
FRotator currentRot = GetActorRotation();
FRotator changeInRot = currentRot - mPrevRot;
FRotator angularVelocity = changeInRot / DeltaSeconds;
mPrevRot = currentRot;
}
}
Ofcourse you would need the correct function signatures and also you would want to encapsulate this into a function. Hope that helped!
There is an angular velocity on the physics body instance. Blueprints even have a Get/SetAngularVelocity which just calls UPrimitiveComponent::GetPhysicsAngularVelocity(FName BoneName). The BoneName isn’t needed and will default to “None” and return the default BodyInstance.