Hi beegeedee, thanks for replying!
This is happening on the server. I tested it again. When standing on the platform, it will move down, but not up, if sweep is enabled. If it’s disabled, this doesn’t happen.
I also checked the object’s details in the editor and it has Simulate Physics disabled.
Here’s the code:
AMovingPlatform::AMovingPlatform(void)
{
PrimaryActorTick.bCanEverTick = true;
SetMobility(EComponentMobility::Movable);
bReplicates = true;
SetReplicatingMovement(true);
}
void AMovingPlatform::BeginPlay()
{
Super::BeginPlay();
StartLocation = GetActorLocation();
TargetLocation = GetTransform().TransformPosition(DestinationOffset);
MoveDistance = (TargetLocation - StartLocation).Length();
}
void AMovingPlatform::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (HasAuthority())
{
MovePlatform(DeltaTime);
}
}
void AMovingPlatform::MovePlatform(float DeltaTime)
{
// Setting sweep to false (or default value) fixes the issue
AddActorWorldOffset((TargetLocation - StartLocation) * DeltaTime / MoveSpeedSeconds, false);
if (FVector::Distance(GetActorLocation(), StartLocation) > MoveDistance)
{
UpdateMoveTarget();
}
}
void AMovingPlatform::UpdateMoveTarget()
{
SetActorLocation(TargetLocation);
FVector TempVector = TargetLocation;
TargetLocation = StartLocation;
StartLocation = TempVector;
}