I am facing an issue with GAS, I need to teleport my character to a specific location with a specific rotation, but it seems there is no way to do this currently, Queue or ScheduleInstantMovementEffect do not seem to take the rotation into account, is this a know issue?
I created my own effect also:
bool FFixedTeleportEffect::ApplyMovementEffect(FApplyMovementEffectParams& ApplyEffectParams,
FMoverSyncState& OutputState)
{
USceneComponent* UpdatedComponent = ApplyEffectParams.UpdatedComponent;
const FRotator FinalTargetRotation = bUseActorRotation ? UpdatedComponent->GetComponentRotation() : TargetRotation;
const FVector PreviousLocation = UpdatedComponent->GetComponentLocation();
const FQuat PreviousRotation = UpdatedComponent->GetComponentQuat();
AActor\* OwnerActor = UpdatedComponent->GetOwner();
if (OwnerActor->TeleportTo(TargetLocation, FinalTargetRotation))
{
const FVector UpdatedLocation = UpdatedComponent->GetComponentLocation();
FMoverDefaultSyncState& OutputSyncState = OutputState.SyncStateCollection.FindOrAddMutableDataByType<FMoverDefaultSyncState>();
OutputSyncState.SetTransforms_WorldSpace(UpdatedLocation,
FRotator::ZeroRotator,
OutputSyncState.GetVelocity_WorldSpace(),
OutputSyncState.GetAngularVelocityDegrees_WorldSpace(),
nullptr ); // no movement base
// TODO: instead of invalidating it, consider checking for a floor. Possibly a dynamic base?
if (UMoverBlackboard\* SimBlackboard = ApplyEffectParams.MoverComp->GetSimBlackboard_Mutable())
{
SimBlackboard->Invalidate(CommonBlackboard::LastFloorResult);
SimBlackboard->Invalidate(CommonBlackboard::LastFoundDynamicMovementBase);
}
ApplyEffectParams.OutputEvents.Add(MakeShared<FTeleportSucceededEventData>(ApplyEffectParams.TimeStep->BaseSimTimeMs, PreviousLocation, PreviousRotation, TargetLocation, FQuat(FinalTargetRotation)));
return true;
}
ApplyEffectParams.OutputEvents.Add(MakeShared<FTeleportFailedEventData>(ApplyEffectParams.TimeStep->BaseSimTimeMs, PreviousLocation, PreviousRotation, TargetLocation, FQuat(FinalTargetRotation), ETeleportFailureReason::Reason_NotAvailable));
return false;
}
The SetTransform_Worldspace seems broken, I have not track the code more in deep to catch the error
