SetActorRotation restarts simulation

Hello,

I’ve created my own character class based on pawn, added movement component, mesh component, capsule collision ect. everything works fine but I’ve noticed some strange behaviour after setting the simulated physical asset to this actor.
Always when actor changes location or rotation then all bones simulated by physics resets their transformation to ‘animation state’.

Is there any magic flag to fix this ?

After some investigation I’ve found something:

void USkeletalMeshComponent::OnUpdateTransform(bool bSkipPhysicsMove)
{
	// We are handling the physics move below, so don't handle it at higher levels
	Super::OnUpdateTransform(true);

	// Always send new transform to physics
	if(bPhysicsStateCreated && !bSkipPhysicsMove )
	{
		UpdateKinematicBonesToPhysics(false, false, true);  
	}

#if WITH_APEX_CLOTHING
	if(ClothingActors.Num() > 0)
	{
		// Updates cloth animation states because transform is updated
		UpdateClothTransform();
	}
#endif //#if WITH_APEX_CLOTHING
}

The “UpdateKinematicBonesToPhysics” is ‘responsible’ for this bug.
Could you tell me why and when execution of UpdateKinematicBonesToPhysics depends on actor movement?

I’ve tested the same physics asset on default “Character” and there is no problem with SetActorRotation so it looks like my implementation of player pawn have some small difference that forces to call on every transformation change UpdateKinematicBonesToPhysics.

Hey Spider-

Here is the documentation on UpdateKinematicBonesToPhysics: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/USkeletalMeshComponent/UpdateKinematicB-/index.html

It seems that when the function is called, the line BodyInstance.SetBodyTransform(CurrentLocalToWorld, bTeleport); may not be getting set properly and is resetting the bones rather than updating based on the movement.

Cheers

Yes, but still cant find what is forcing other behavior for Pawns than Character. I have simple repro for this problem:

  1. Create blueprint from Pawn
  2. Add skeletal mesh component to Pawn_BP
  3. Set the mesha/physics asset/simple animation blueprint
  4. Set collision to block all
  5. From event tick call the “Add Actor Local Offset” with some offset

See the shaking physics bodies that jumps into bone animation location.

Hey Spider-

I’m not sure I’m seeing the same thing that you’re describing through your repro steps. Could you post a screenshot of how your blueprint and animation blueprint are setup? A short video of the behavior you are experiencing will also be help give us an idea of what exactly is happening.

Hey ,

I found what is the problem. I had to add this line into my implementation of Pawn:

Mesh->PrimaryComponentTick.AddPrerequisite(MovementComponent, MovementComponent->PrimaryComponentTick);

Fixed. Thanks for helping! :slight_smile: