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

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



// 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);

}



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.

It’s taking me hours and hours to find the solution for simply ROTATING an object. In my case it’s a flag blowing in the wind. And for the life of me I cannot find a solution for this problem. The object scales, moves, and doesn’t rotate. Honestly, as much as this program has some cool features, it also totally sucks. I won’t even bother waiting for a reply. Just wanted you guys to know the way you’ve set up UE’s nodes system is infinite suckage. The spaghetti disaster. Absolutely awful wasting precious time over something that should take less than one second. You guys have a LONG WAY TO GO before you go puffing your chests out. Super lame.

1 Like