Download

Can't Add AWindDirectionalSource to my code

Title speaks for it self. I try to add the AWindDirectionalSource to my code but its throw up an insane amount of error messages.
It’s an interesting thing because it’s say that I froget a “;”… Can anyone help, or did anyone get this error/problem before?
Thanks for anything: MetalHunterR

Code:



#pragma once

#include "GameFramework/Actor.h"
#include "SWeatherType.h"
#include "SWeatherManager.generated.h"

UCLASS()
class SQUADKILL_API ASWeatherManager : public AActor
{
	GENERATED_BODY()

	// Sets default values for this actor's properties
	ASWeatherManager();
	
public:	
	// Atmospheric Fog settings of the weather
	UPROPERTY(EditAnywhere)
	AAtmosphericFog* AtmosphericFogComp;

	// Exponential Fog settings of the weather
	UPROPERTY(EditAnywhere)
	AExponentialHeightFog* ExponentialFogComp;

	// Wind settings of the weather
	UPROPERTY(EditAnywhere)
	AWindDirectionalSource*  WindComp;

protected:
	/*An array of the associated weathers*/
	UPROPERTY(EditAnywhere)
	TArray<ASWeatherType*> Weathers;
};


Errors:



2>D:\Unreal Projects\SquadKill\Source\SquadKill\Public/Weather/SWeatherManager.h(28): error C2143: syntax error: missing ';' before '*'
2>D:\Unreal Projects\SquadKill\Source\SquadKill\Public/Weather/SWeatherManager.h(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>D:\Unreal Projects\SquadKill\Source\SquadKill\Public/Weather/SWeatherManager.h(28): error C2238: unexpected token(s) preceding ';'
2>D:\Unreal Projects\SquadKill\Intermediate\Build\Win64\UE4Editor\Inc\SquadKill\SquadKill.generated.cpp(5311): error C2039: 'WindComp': is not a member of 'ASWeatherManager'
2>  D:\Unreal Projects\SquadKill\Source\SquadKill\Public/Weather/SWeatherManager.h(10): note: see declaration of 'ASWeatherManager'
2>D:\Unreal Projects\SquadKill\Intermediate\Build\Win64\UE4Editor\Inc\SquadKill\SquadKill.generated.cpp(5311): error C2664: 'UObjectProperty::UObjectProperty(const UObjectProperty &)': cannot convert argument 1 from 'FObjectInitializer' to 'ECppProperty'
2>  D:\Unreal Projects\SquadKill\Intermediate\Build\Win64\UE4Editor\Inc\SquadKill\SquadKill.generated.cpp(5311): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
2>D:\Unreal Projects\SquadKill\Source\SquadKill\Public\Weather\SWeatherManager.h(28): error C2143: syntax error: missing ';' before '*'
2>D:\Unreal Projects\SquadKill\Source\SquadKill\Public\Weather\SWeatherManager.h(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>D:\Unreal Projects\SquadKill\Source\SquadKill\Public\Weather\SWeatherManager.h(28): error C2238: unexpected token(s) preceding ';'


This part is the key:



missing type specifier - int assumed. Note: C++ does not support default-int


It means it doesn’t know what the ‘type’ is, in this case it doesn’t know what an ‘AWindDirectionalSource’ is - and it probably doesn’t know the others either. In order for this to work, you need to add the following above the ‘UCLASS’ macro in the header file:



class AWindDirectionalSource;
class AExponentialHeightFog;
class AAtmosphericFog;


This is known as ‘Forward Declaration’. If you want to call functions or access variables of those objects in the .cpp file, you’ll also need to include the headers in the .cpp file (do NOT include them in the header, this is bad practice and leads to bloated binaries and circular dependencies). e.g:



#include "WindDirectionalSource.h"
#include "ExponentialHeightFog.h"


I don’t know where or what the headers are so you’ll have to search for those yourself.


The next thing of note - is that you’re using ‘AWindDirectionalSource’, and the ‘A’ at the beginning denotes that this is an actor. I’m assuming this is an object you’re going to place into the world, and set those parameters from already-existing objects in the details panel. That’s fine, but if you want them to be component of your weather manager, you’ll need to use the components and not the actors.

Thank you, it’s working!