Download

Rotation problem on actor with physics

if you throw an object and set new rotation value, and after that trying to set simulate physics to true without a delay it doesn’t work. and sometimes it is says set the teleport option

without a delay it works as expected

expected result: it rotates the object and set the simulate physics w/o a delay
actual result :it simulates physics but w/o rotation.

so the actual application of this thing is to drop a weapon, rotate it as I wish and set simulate physics to true add impulse and see how it is falling down

I would like to make it like in Borderlands 2/3

I do appreciate any help! Thank you for your time!
​​​

Can you show the hierarchy of that object? Is static mesh the root here?

Sure, here you go - images attached or url:

Cube is StaticMeshComponent (root is the DefaultSceneRoot). Weapon is SkeletalMeshComponent (the root too)

Could you please take a look at another problem?
Link – it is about client jitters on both server and its own side.

When simulating physics always ensure the simulating mesh is the root. Otherwise you’ll get inconsistent results.

Not my field. Sorry.

The Cube start working in deed!
**BUT ONLY IF **you set the root component StaticMeshComponent and set the order like this:

  1. set simulate physics - TRUE;
  2. SetActorRotation(X, Y, Z) https://docs.unrealengine.com/en-US/…ion/index.html]

CRUCIAL: If you do in a reverse order (1. SetActorRotation(X, Y, Z) **2. **set simulate physics to TRUE), It will NOT work.

1st Screenshot

Thank you for that! [HR][/HR]
2nd Screenshot
But there’s another problem with SkeletalMeshComonent
it does not work neither for SetActorRotation ( FRotator NewRotation, ETeleportType Teleport )https://docs.unrealengine.com/en-US/…ion/index.html]
nor SetWorldRotation/SetRelativeLocation

If I try to drop my weapon like in the screenshot down below it shows the warning

BP of the schema by URL:BP drop weapon(skeletalmesh), shows warning posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4

Most of the project is in C++, so the code is down below[this way the rotation does not work.]:
[SPOILER]



// HEADER File:
    UFUNCTION()
    void EnablePhysicsAndAddImpulse(FRotator DropDirection, int32 DropForc);
// End of HEADER File

// CPP file
void ASWeapon::SetUpParamsAndDropIt_Implementation(FRotator DropDirection, int32 DropForce)
{
    if (this == nullptr) {
        return;
    }
    bIsReloading = false;
    DropDirection.Pitch = 45;

    //AActor* Owner = Cast<ASCharacter>(GetOwner());
    FRotator BaseRot = GetActorRotation();
    //BaseRot.Yaw = 150;
    BaseRot.Pitch += 45;
    SetOwner(nullptr);

    SetActorRotation(BaseRot.Quaternion());
    //SkeletalMeshComp->SetWorldRotation(BaseRot.Quaternion());
    //SkeletalMeshComp->SetRelativeRotation(BaseRot.Quaternion());
    SkeletalMeshComp->SetSimulatePhysics(false);
    SkeletalMeshComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
    SkeletalMeshComp->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block);
}


[this code which works but with a delay]



// HEADER File:
    UFUNCTION(NetMulticast, Reliable, WithValidation)
    void SetUpParamsForPickUp();
    UFUNCTION(NetMulticast, Reliable, WithValidation)
    void SetUpParamsAndDropIt(FRotator DropDirection, int32 DropForce);

    UFUNCTION()
    void EnablePhysicsAndAddImpulse(FRotator DropDirection, int32 DropForc);

// End of HEADER File

// CPP file
void ASWeapon::SetUpParamsForPickUp_Implementation()
{

    SkeletalMeshComp->SetSimulatePhysics(false);
    SkeletalMeshComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
    SkeletalMeshComp->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block);
}

bool ASWeapon::SetUpParamsForPickUp_Validate()
{
    return  true;
}

// only for Server


void ASWeapon::SetUpParamsAndDropIt_Implementation(FRotator DropDirection, int32 DropForce)
{
    if (this == nullptr) {
        return;
    }
    bIsReloading = false;
    DropDirection.Pitch = 45;

    //AActor* Owner = Cast<ASCharacter>(GetOwner());
    FRotator BaseRot = GetActorRotation();
    //BaseRot.Yaw = 150;
    BaseRot.Pitch += 45;
    SetOwner(nullptr);

    SetActorRotation(BaseRot.Quaternion());
    //SkeletalMeshComp->SetWorldRotation(BaseRot.Quaternion());
    //SkeletalMeshComp->SetRelativeRotation(BaseRot.Quaternion());


    FTimerDelegate TimerDel;
    FTimerHandle TimerHandle;

    //Binding the function with specific variables
    TimerDel.BindUFunction(this, FName("EnablePhysicsAndAddImpulse"), DropDirection, DropForce);
    //Calling MyUsefulFunction after 5 seconds without looping
    GetWorldTimerManager().SetTimer(TimerHandle, TimerDel, 0.001, false);

}



[/SPOILER]

Thank you very much for this. I will take it into my accout!

Please take a look at the SkeletalMeshComponent example either in BP or C++ as you wish.