What is required to be able to write PhysX code / use physics types? Including PhysX module is not sufficient

Dear Friends at Epic,

I would like to do some PhysX code writing in DestructibleComponent sublcass that is contained with my game’s project module.

I am not writing engine code, just project level code

I included PhysX as a module in my Build.cs!

I added these includes in my subclassed DestructibleComponent.cpp

#include "PhysicsPublic.h"
//#include "PhysicsEngine/PhysXSupport.h"
//#include "Collision/PhysXCollision.h"

I wrote some sample code:

//testing stuff
	#if WITH_PHYSX
	for(FDestructibleChunkInfo& Each : DestructibleComponent->ChunkInfos)
	{
		physx::PxRigidDynamic* Actor = Each.Actor;
		 
		if(Actor)
		{
			PxTransform Trans = Actor->GetGlobalPose();
			PxVec3 PxLoc = Trans.p;
			
			FVector Location(PxLoc.x,PxLoc.y,PxLoc.z);
			
			DrawPoint(Location);
		}
	}
	#endif // WITH_PHYSX 

#Issues

The two includes I have commented out wont compile!

//#include "PhysicsEngine/PhysXSupport.h"
//#include "Collision/PhysXCollision.h"

Compile says it cannot open these includes

#Compile Errors

And when I compile I get these errors:

1>------ Build started: Project: JoyShapes, Configuration: Development_Editor x64 ------
1>  Performing 2 actions (max 4 parallel jobs)
1>  Module.JoyShapes.1_of_3.cpp
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(167): error C2079: 'Trans' uses undefined class 'physx::PxTransform'
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(167): error C2027: use of undefined type 'physx::PxRigidDynamic'
1>          E:\VictoryUE4\UnrealEngine-4.3\Engine\Source\Runtime\Engine\Classes\PhysicsEngine/BodyInstance.h(19) : see declaration of 'physx::PxRigidDynamic'
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(167): error C2227: left of '->GetGlobalPose' must point to class/struct/union/generic type
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(168): error C2079: 'PxLoc' uses undefined class 'physx::PxVec3'
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(168): error C2228: left of '.p' must have class/struct/union
1>          type is 'int'
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(170): error C2228: left of '.x' must have class/struct/union
1>          type is 'int'
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(170): error C2228: left of '.y' must have class/struct/union
1>          type is 'int'
1>C:\Users\\Documents\Unreal Projects\JoyShapes\Source\JoyShapes\Private\Base\JoyDestruction.cpp(170): error C2228: left of '.z' must have class/struct/union
1>          type is 'int'
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\\Documents\Unreal Projects\JoyShapes\Binaries\Win64\UE4Editor-JoyShapes.pdb
1>  Cumulative action seconds (8 processors): 0.00 building projects, 8.58 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.00 linking, 0.00 other
1>  UBT execution time: 23.08 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "E:\VictoryUE4\UnrealEngine-4.3\Engine\Build\BatchFiles\Build.bat JoyShapesEditor Win64 Development "C:\Users\\Documents\Unreal Projects\JoyShapes\JoyShapes.uproject"" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

#Question

What do I need to do so I can work with the Px var types?

#Thanks!

Thanks!

Did you add folder containing PhysicsEngine folder and Collision folder to your PublicIncludePaths in your Build.cs file?

When I added PhysicsEngine as a module to my build CS, VS threw an exception cause it could not find PhysicsEngine!

!

:slight_smile:

Mind to show your Build.cs? Because its really strange.
I’m using third party libraries and never met such problems.

I’m telling you, VS wont compile “PhysicsEngine” module :slight_smile:

Have you been able to add the module PhysicsEngine as you are suggesting that I do?

PublicDependencyModuleNames.AddRange(new string[] { 
                "Core", 
                "CoreUObject", 
                "Engine", 
                "InputCore",
                
                "RHI", 
                "RenderCore", 
                "ShaderCore",

                "OnlineSubsystem",
				"OnlineSubsystemUtils",

                "Sockets","Networking",

                "PhysX",
                "PhysicsEngine",
                "Collision",

                "AIModule"
        });

1>------ Build started: Project: JoyShapes, Configuration: Development_Editor x64 ------
1>EXEC : error : Exception thrown while processing dependent modules of JoyShapes
1>EXEC : error : Couldn't find module rules file for module 'PhysicsEngine'.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "E:\VictoryUE4\UnrealEngine-4.3\Engine\Build\BatchFiles\Build.bat JoyShapesEditor Win64 Development "C:\Users\\Documents\Unreal Projects\JoyShapes\JoyShapes.uproject"" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Seems like I got you wrong. I thought you’re using PhysX SDK downloaded from nvidia. =)

I’ll try this and see if it will go wrong.

Any update on this?

I’d love to do some NVidia coding using the engine as is, but if I need an SDK I will be happy to use it. :slight_smile:

Nope :frowning: I can’t even include PhysicsPublic.h because it gives a lot of compile errors.

I answerd your qustion if it stile don`t work i may have forgoten something let me know and we will figuer it out.

Woohoo thanks for the help !

Will let you know soon as I get a test working :slight_smile:

Realy glad i could help out and nice wiki, i have been doing a lot of un-necesary steps it seems.:slight_smile:

#Woohoo!

Victory!

Thanks !

I just needed that 1 include!

I’ve posted a wiki about it, feel free to create an additional one or add your own section to mine with additional code samples, putting your signature by your code (can use the short cut of ~~~ for wiki signature)

#.h

PS: if you convert your response to an answer I can give you credit :slight_smile:

Thanks Again for the tip about that include !

#:heart:

My plesure :slight_smile: glad i could help.