Actor location being overwritten

I have the following code:

void AWeaponBase::OnThrow()
{
	if (CurrentOwner)
	{
		const ACharacter* ThrowingOwner = CurrentOwner;
		DetachFromCurrentOwner();

		const APlayerCameraManager* CameraManager = UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0);

		const FVector StartThrowLocation = CameraManager->GetCameraLocation() + FRotationMatrix(CameraManager->GetCameraRotation()).GetScaledAxis(EAxis::X) * 100.0f;

		SetActorLocation(StartThrowLocation, false, nullptr, ETeleportType::ResetPhysics);
	}
}

When I run it, the weapon actor should be teleported in front of the player, but it just drops to the ground.

I realized that the reason for this is not that the weapon is not being moved, but rather that it’s being returned to the original position in the next frame. However, I can’t figure out where it’s being moved back. I don’t know if it has something to do with physics simulation or what’s happening. Can somebody help?

I found a way to fix it. I disabled physics before moving the actor and the enabled physics after moving it. Although it works, it seems kind of unreasonable, especially since there is a flag that specifically says “Reset Physics”. If someone can still help me with this problem, I would be really thankful

What is the actor’s root component? if it’s not the component that is set to simulate physics, Set Actor Location won’t work as you intended. Well it will work, and the root (whether it was a Scene or anything else) changes location but the component that is simulating physics will stay in its place relative to it. Set the root to the component that is simulating physics and it will work as you want it to.

Hey, thanks for the reply. I’m pretty sure the RootComponent is my Skeletal Mesh, though. This is my code:

    AWeaponBase::AWeaponBase()
    {
     	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    	PrimaryActorTick.bCanEverTick = true;
    
    	WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(FName("WeaponMesh"));
    	WeaponMesh->bEditableWhenInherited = true;
    	RootComponent = WeaponMesh;
    
    	WeaponType = EWeaponType::Basic;
    }

Am I missing anything?

Nope that’s it, just use ETeleportType::TeleportPhysics instead of ResetPhysics and it’ll work. I just tested it to make sure.