I’m working on a racing game, and I need to be able to teleport a WheeledVehicle to reset the player if they’re out of bounds of the track.
In an older version of UE4 (4.7) I wrote custom C++ code to do this, and it worked without any issues. But in 4.16 and now 4.17, I get this warning:
“Attempting to move a fully simulated skeletal mesh VehicleMesh. Please use the Teleport flag”
Even if I use the Teleport Blueprint node, and also with the SetActorLocationAndRotation node (with the Teleport flag set to True), I still get the warning.
I found this AnswerHub post from a few years ago, which says to SetSimulatePhysics to false, then teleport, and then SetSimulatePhysics to true. When I try this, the wheels fall off of the vehicle after the teleport (and also with setting the Actor location); while hilarious, but not really the effect I’m wanting… and the warning still shows up.
What am I missing? How to I “use the Teleport flag” if it isn’t the Teleport flag on the SetActorLocationAndRotation Blueprint node?
bool USkeletalMeshComponent::MoveComponentImpl(const FVector& Delta, const FQuat& NewRotation, bool bSweep, FHitResult* OutHit /*= nullptr*/, EMoveComponentFlags MoveFlags /*= MOVECOMP_NoFlags*/, ETeleportType Teleport /*= ETeleportType::None*/)
{
#if WITH_EDITOR
UWorld* World = GetWorld();
if(World && World->IsGameWorld())
{
if (FBodyInstance* BI = GetBodyInstance())
{
//If the root body is simulating and we're told to move without teleportation we warn. This is hard to support because of bodies chained together which creates some ambiguity
if (BI->IsInstanceSimulatingPhysics() && Teleport == ETeleportType::None && (MoveFlags&EMoveComponentFlags::MOVECOMP_SkipPhysicsMove) == 0)
{
FMessageLog("PIE").Warning(FText::Format(LOCTEXT("MovingSimulatedSkeletalMesh", "Attempting to move a fully simulated skeletal mesh {0}. Please use the Teleport flag"),
FText::FromString(GetNameSafe(this))));
}
}
}
#endif
return Super::MoveComponentImpl(Delta, NewRotation, bSweep, OutHit, MoveFlags, Teleport);
}
So first the warning should only ever be in editor and second make sure to not trigger this if statement
if (BI->IsInstanceSimulatingPhysics() && Teleport == ETeleportType::None && (MoveFlags&EMoveComponentFlags::MOVECOMP_SkipPhysicsMove) == 0)
Probably the issue is teleport type should be TeleportPhysics and isn’t.
When I called the MoveComponent function (which in turn calls the above quoted function), the WheeledVehicle teleports, but not to the location I expect.
For now, what is working, albeit with the warning, is to call the following two functions to teleport the WheeledVehicle: USkeletalMeshComponent::SetAllPhysicsPosition
[USkeletalMeshComponent::SetAllPhysicsRotation
If the warning is only in the Editor, then I may keep it like this for now.