C++ Transition Guide for 4.21

Dear Community,

This is the thread where you can post all your questions and solutions as you upgrade your project to 4.21!


**error C2039: 'GetPhysXScene': is not a member of 'FPhysScene_PhysX'**



```


PxScene* PScene = PhysScene->GetPhysXScene(PST_Sync);


```



becomes



```


PxScene* PScene = PhysScene->GetPxScene(PST_Sync);


```



**‘GetPxRigidActor_AssumesLocked’: is not a member of ‘FBodyInstance’ error.



PxRigidActor* PRigidActor = Body->GetPxRigidActor_AssumesLocked();


becomes



#if WITH_PHYSX && PHYSICS_INTERFACE_PHYSX
    PxRigidActor* PRigidActor = FPhysicsInterface::GetPxRigidActor_AssumesLocked(BodyInstance->GetPhysicsActorHandle());
#endif



Enjoy!

♥

Rama

Anyone running into this?

After switching to 4.21, git status always give this:



Untracked files:
(use "git add <file>..." to include in what will be committed)
IOS/IOSTargetPlatform/Private/IOSTargetDeviceOutput.h
IOS/IOSTargetPlatform/Private/IOSTargetDeviceOutput.inl


But if I delete the files manually it gives:



Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory) deleted:
    iOS/IOSTargetPlatform/Private/IOSTargetDeviceOutput.h deleted:
    iOS/IOSTargetPlatform/Private/IOSTargetDeviceOutput.inl


it seems they are both tracked and not tracked?

Looking at 4.21 git log of the files, it seems those two files were deleted and re-added due to some kind of case sensitivity issue, and you can see the folder goes from IOS to iOS in the status messages. On my system it is IOS, but on github it is listed as IOS too. If I change it to iOS I instead start getting:



Untracked files:
  (use "git add <file>..." to include in what will be committed)

        iOS/IOSPlatformEditor/
        iOS/IOSTargetPlatform/IOSTargetPlatform.Build.cs
        iOS/IOSTargetPlatform/Private/IOSDeviceHelper.h
        iOS/IOSTargetPlatform/Private/IOSTargetDevice.cpp
        iOS/IOSTargetPlatform/Private/IOSTargetDevice.h
        iOS/IOSTargetPlatform/Private/IOSTargetPlatform.cpp
        iOS/IOSTargetPlatform/Private/IOSTargetPlatform.h
        iOS/IOSTargetPlatform/Private/IOSTargetPlatformModule.cpp
        iOS/IOSTargetPlatform/Private/Mac/
        iOS/IOSTargetPlatform/Private/Windows/
        iOS/TVOSTargetPlatform/


but it clears up the other two files…

Since upgrading to 4.20 from 4.19, I have been having this issue with the steam dependency, has anyone else ran into this problem?

Trying to upgrade my toolkit for the market place and everything plays fine in the editor and standalone but now when I publish the example game it creates then i try to load a level pass the title screen and it just crashed with no real path as to what is wrong:

Access violation - code c0000005 (first/second chance not available)

RPGPluginTest!UObject::CallFunction()
RPGPluginTest!UObject::execLetBool()
RPGPluginTest!UObject::ProcessInternal()
RPGPluginTest!UObject::CallFunction()
RPGPluginTest!UObject::ProcessInternal()
RPGPluginTest!UFunction::Invoke()
RPGPluginTest!UObject::ProcessEvent()
RPGPluginTest!AActor::ProcessEvent()
RPGPluginTest!FLatentActionManager::TickLatentActionForObject()
RPGPluginTest!FLatentActionManager::ProcessLatentActions()
RPGPluginTest!AActor::Tick()
RPGPluginTest!AActor::TickActor()
RPGPluginTest!FActorTickFunction::ExecuteTick()
RPGPluginTest!FTickFunctionTask::DoTask()
RPGPluginTest!TGraphTask<FTickFunctionTask>::ExecuteTask()
RPGPluginTest!FNamedTaskThread::ProcessTasksNamedThread()
RPGPluginTest!FNamedTaskThread::ProcessTasksUntilQuit()
RPGPluginTest!FTickTaskSequencer::ReleaseTickGroup()
RPGPluginTest!FTickTaskManager::RunTickGroup()
RPGPluginTest!UWorld::RunTickGroup()
RPGPluginTest!UWorld::Tick()
RPGPluginTest!UGameEngine::Tick()
RPGPluginTest!FEngineLoop::Tick()
RPGPluginTest!GuardedMain()
RPGPluginTest!GuardedMainWrapper()
RPGPluginTest!WinMain()
RPGPluginTest!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253]
kernel32
ntdll

So far I’ve tried using the command line to compile just the plugin and its giving me errors about including object.h not being found. So far I’ve tried to change my build.cs from:

bEnforceIWYU = true;
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

to

bEnforceIWYU = true;
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
bEnableExceptions = true;

PCHUsage = ModuleRules.PCHUsageMode.NoSharedPCHs;
PrivatePCHHeaderFile = “Public/RPGEngineToolKit.h”;

and now it’s asking me to remove every place i used minimal.h so maybe after all then IWYU changes ill finally be able to run my published build?

Is there a place where they specify the c++ side of changes in new releases?

I had the same issue and added these codes in GameInstance Construct.


if (!HasAnyFlags(RF_ClassDefaultObject))
{
    FString RootSteamPath = FPaths::EngineDir() / STEAM_SDK_ROOT_PATH / STEAM_SDK_VER_PATH / TEXT("Win64/");
    FPlatformProcess::PushDllDirectory(*RootSteamPath);
}

Looks like PhysicX has trouble with seamless travel. crashed with PhysX3PROFILE_x64.dll and PhysX3_x64.dll.
Anyone knows the best practice?

PhysX3CHECKED_x64.dll is fine.


public ProjectTarget(TargetInfo Target) : base(Target)
{
    Type = TargetType.Game;
    bUsesSteam = true;
    bUseCheckedPhysXLibraries = true;
    bUseShippingPhysXLibraries = false;


So I’m experiencing something rather odd, I transitioned a test project for 4.20 to 4.21 with no issues at all, So I went ahead and did the same thing with my main project. Now, all of my includes for anything to do with UE4 cannot be opened. Took some screenies of the problem at hand (I’ve used CoreMinimal as a focus point).

It appears as if it no longer has the right path to any of the engine headers (2nd screenshot does not include the Public folder of Runtime/Core), all of these worked fine on 4.20, and continues to work fine if I change the engine type back. It also appears to change from using Community 2015 to Community 2017, not sure if this has something to do with it?

Any help would be appreciated, I’d like to keep our project on the latest engine while it is still viable to do so.

If anyone else gets this problem (even though it was a really dumb error on my move), you may have to remove some plugins that do not work with 4.21 from your target.cs files.

I’ve been having serious troubles to make UE4.21 work.

  • Had to modify most of my build.cs files because all the relative paths were resolved using the engine’s directory. I modified these .cs files replacing things like [FONT=courier new]moduleName/public with [FONT=courier new]Path.Combine(ModuleDirectory, “Public”)
  • Various properties became private and had to replace them with the new Getters (this is ok and pretty sensible thing to have regardless)
  • Maybe it’s just me but this whole private PCH thing is quite confusing. I know what a PCH is and what it does but the way unreal uses them and how it affects the compilation… it’s confusing. Why do I have to specify a PrivatePCHHeaderFile if I set PCHUsageMode.NoSharedPCHs?
  • Now in my playerController::BeginPlay if I pass to some of my objects a pointer to the player controller it becomes STALE !

I’ve been updating the engine’s source every release since 4.11 and this time I skipped 4.20 and went directly from 4.19 to 4.21.

I updated to 4.21.1 and now all my destructible assets have gone crazy. There is a brick wall and when it breaks apart the bricks bounce all around like rubber balls. I have a monster trucks that fly’s like a kit in a storm. How am i supposed to fix all of this :frowning:

Anybody got a fix for this one: error C2039: ‘RigidActorSync’: is not a member of ‘FBodyInstance’


    TArray<AActor*> Actors;
    UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), Actors);

    for (AActor* Actor : Actors)
    {
        AStaticMeshActor* StaticActor = Cast<AStaticMeshActor>(Actor);
        if (!StaticActor) continue;

        FBodyInstance* ActorBI = StaticActor->GetStaticMeshComponent()->GetBodyInstance();
        if (!ActorBI) continue;

        PhysxActors.Add(ActorBI->RigidActorSync);
        PxActor* PhysXActor = ActorBI->RigidActorSync;
    }

Been trying to resolve this and haven’t been able to.

This:


PhysxActors.Add(ActorBI->RigidActorSync);
PxActor* PhysXActor = ActorBI->RigidActorSync;

Becomes:


PhysxActors.Add(FPhysicsInterface::GetPxRigidActor_AssumesLocked(ActorBI->GetPhysicsActorHandle()));
PxActor* PhysXActor = FPhysicsInterface::GetPxRigidActor_AssumesLocked(ActorBI->GetPhysicsActorHandle());

Error " Expedition Contains illegal character ‘%’ "

That’s a bit too vague. What is the offending line of code?

hi all =)

I’m not coder, and using ue4 just for education and fun
Excuse me, if my issue isnt in correct forum branch

I need a dedicated windows server for my future project, so i ve found this page with FAQ

But those instructions re compatible with <4.18 ue4 version. I ve 4.19/4.21 on my PC.

Can anyone help me with target file instructions for engine version 4.21 ?
Thx for any reply =)

hello, I have tried to understand a bit how the problem is solved but I can not update, could someone suggest me how to write the fragment of code?


void UForceDirectedController::BeginPlay()
{
    Super::BeginPlay();        
    AStaticMeshActor* Node = GetStaticMeshActor(this);
    if (Node) {
        UStaticMeshComponent* SMC = Node->GetStaticMeshComponent();
        if (SMC) {

            PxRigidBody = SMC->GetBodyInstance()->GetPxRigidBody_AssumesLocked(); // Error 
            if (Root) {
                Nodes.Empty();
                GatherNodes(Node);
            }
        }
    }
    //DistributeNodes(10);
}

why not keep using the mature version for serious production?

Hi i have problem with updating project from 4.20.3 to 4.21.2. With this error:
Was only expecting C++ files to have CachedCPPEnvironments!
Do u know anyone what is wrong???

didnt’ their used to be more pages to this thread? how do i set build settings = v.2 in my target.cs ? it seems like all the info about how to do this stuff is now gone