The Cube start working in deed!
**BUT ONLY IF **you set the root component StaticMeshComponent and set the order like this:
- set simulate physics - TRUE;
- 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);
}