ChaosVehicles causes errors if I have too many UStructs UE5.2

Requirements to recreate issue:

  • UE5.2
  • ChaosVehicles enabled and Including “ChaosWheeledVehicleMovementComponent.h” in any header file, that is in use
  • a bunch of UStructs and/or variables within them

I was adding some new structs in C++, to be used as data structures. Everything worked fine, until I get this, completely unrelated to what I am doing:


[2/3] Compile [x64] Module.Project.2_of_2.cpp
C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\Evolution\IterationSettings.h(26): error C4003: not enough arguments for function-like macro invocation ‘max’
C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\Evolution\IterationSettings.h(26): error C2589: ‘(’: illegal token on right side of ‘::’
C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\Evolution\IterationSettings.h(26): error C2062: type ‘unknown-type’ unexpected
C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\Evolution\IterationSettings.h(26): error C2059: syntax error: ‘)’

[3/3] Compile [x64] Module.Project.1_of_2.cpp

I can get rid of these errors either by completely disabling ChaosVehicles, or by removing some UStructs. So basically this limits me to a certain amount of UStructs. Having variables inside those structs also limit this amount.
Here is an example structure of what im using:

USTRUCT(BlueprintType)
struct FExampleStruct
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere)
bool exampleA = true;

UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (UIMin = “0”, UIMax = “1”)) float exampleB= 1.0f;
};

Is there something wrong with my struct, is this a known problem with Chaos, or something else?
I can expand upon this, if I didn’t give enough information.

Hi, I’m not entirely sure but you can try these 3 things:

  1. Add “ChaosVehicles” module to your build.cs
  2. I never use GENERATED_USTRUCT_BODY(), but GENERATED_BODY() like in the doc: Structs in Unreal Engine | Unreal Engine 5.0 Documentation I’m not sure if there is any difference, but you could try changing it.
  3. If those things doesn’t work try non-unity build (you need to add bUseUnityBuild = false; to your target.cs)
1 Like

Hi, thanks for the quick reply.
I’ve tried all of these, but no luck :frowning:

I was originally using GENERATED_BODY(). No idea what the difference is, but neither work.

Is there something else I need to do when disabling unity build. I tried recompiling in the editor after adding that to my target.cs, and also re-generating Visual Studio files after that didn’t work.

No, that target.cs change forces to use non-unity build, so everything should be recompiled after that.

Is there a chance that one or some of your structs use the same name as something in that ChaosVehicle plugin? Maybe try just renaming them?

1 Like

I doubt they do, mine are weather themed. Also, I can comment out one struct & keep the other uncommented, and it works. It also works if swap those around. However if I try to use them both at the same time, it doesn’t work.
Currently I’m commenting out some variables inside those structs, and if I were to uncomment those, the errors happen again.

I should also mention it doesn’t matter where the structs are located. I tried adding them to different files with no luck.

Makes no sense to me

Hmm sorry I don’t have any other idea. It really looks like something for non-unity build, but if you say that it doesn’t help, it’s very hard to say. Maybe someone more experienced can help.
Definitely there is no such thing as UStructs limit.

1 Like

Yeah, seems like so. I’ll have to try again at a later date with a non-unity build. Thanks for the help.

Header

#pragma once

#include "CoreMinimal.h"
#include "ChaosVehicles.h"
#include "MyChaosVehicles.generated.h"

USTRUCT(BlueprintType)
struct FExampleStruct
{
	GENERATED_USTRUCT_BODY()
public:
	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	bool exampleA = true;
	
	UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (UIMin = "0", UIMax = "1"))
		float exampleB = 1.0f;
};


class UChaosWheeledVehicleMovementComponent;

/**
 * 
 */
UCLASS()
class UT_API UMyChaosVehicles : public UChaosVehicles
{
	GENERATED_BODY()

	UMyChaosVehicles(FObjectInitializer const& ObjectInitializer);

	UChaosWheeledVehicleMovementComponent* MovementComp;

};

CPP

#include "MyChaosVehicles.h"
#include "ChaosWheeledVehicleMovementComponent.h" 

UMyChaosVehicles::UMyChaosVehicles(FObjectInitializer const& ObjectInitializer) : Super(ObjectInitializer) 
{
	MovementComp = CreateDefaultSubobject<UChaosWheeledVehicleMovementComponent>(TEXT("MC"));
}

build has “ChaosVehicles”

Compiles fine.

Perhaps you shouldn’t be including the header files in your header.
Include them in your cpp and forward declare any needed variables, otherwise you can have cyclic inclusions and other bad side effects.

Also the quotation marks in your code were strange
(UIMin = “0”, UIMax = “1”)
sort of curly like not properly formatted double quotations (perhaps it’s a forum thing but haven’t noticed it anywhere else)

this is what it looks like in my code
(UIMin = "0", UIMax = "1")

Could it be converted quotes that are throwing off the compiler?

1 Like

Hi, sorry for the late reply. I tried again with a non-unity build today and everything works now. I guess I messed it up before. Thanks for the help!

All I needed to do was to disable that.

Seems like it also now works after refactoring the code to look like yours. (Files that use ChaosVehicles)

I guess this was the underlying issue, which disabling unity build fixes. Thanks for the help.

Also the quotation marks are definitely a forum thing :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.