Hello,
I try to make a simple USTRUCT in C++, that has two properties, one Actor, and a FName:
This is my WeaponSlot.h
#pragma once
#include “Weapon.h”
#include “WeaponSlot.generated.h”
USTRUCT()
struct FWeaponSlot
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=WeaponSlot)
FName socketName;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeaponSlot)
AWeapon* weapon;
};
AWeapon is just an Class derived from ACtor, that I did not touch yet.
#pragma once
#include "Item.h"
#include "Weapon.generated.h"
/**
*
*/
UCLASS()
class SLAVES_API AWeapon : public AItem
{
GENERATED_UCLASS_BODY()
};
I try to use my struct inside my own Component:
#pragma once
#include "Weapon.h"
#include "WeaponSlot.h"
#include "Components/ActorComponent.h"
#include "WeaponControllComponent.generated.h"
UCLASS(meta = (BlueprintSpawnableComponent))
class SLAVES_API UWeaponControllComponent : public UActorComponent
{
GENERATED_UCLASS_BODY()
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = WeaponControll)
TArray<FWeaponSlot> weaponSlots;
UFUNCTION(BlueprintCallable, Category = WeaponControll)
void FireAllWeapons();
};
Here is the error oputput I get (sorry only in german :()
1>------ Erstellen gestartet: Projekt: Slaves, Konfiguration: DebugGame_Editor x64 ------
1> Performing 2 actions (max 4 parallel jobs)
1> Slaves.generated.cpp
1>D:\dev\Unreal Projects\Slaves\Intermediate\Build\Win64\Inc\Slaves\Slaves.generated.cpp(118): error C2039: 'Weapon': Ist kein Element von 'FWeaponSlot'
1> D:\dev\Unreal Projects\Slaves\Source\Slaves\WeaponSlot.h(9): Siehe Deklaration von 'FWeaponSlot'
1>D:\dev\Unreal Projects\Slaves\Intermediate\Build\Win64\Inc\Slaves\Slaves.generated.cpp(118): error C2661: 'UObjectProperty::UObjectProperty': Keine überladene Funktion akzeptiert 4 Argumente
1>D:\dev\Unreal Projects\Slaves\Intermediate\Build\Win64\Inc\Slaves\Slaves.generated.cpp(119): error C2039: 'SocketName': Ist kein Element von 'FWeaponSlot'
1> D:\dev\Unreal Projects\Slaves\Source\Slaves\WeaponSlot.h(9): Siehe Deklaration von 'FWeaponSlot'
1>D:\dev\Unreal Projects\Slaves\Intermediate\Build\Win64\Inc\Slaves\Slaves.generated.cpp(119): error C2661: 'UNameProperty::UNameProperty': Keine überladene Funktion akzeptiert 3 Argumente
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: D:\dev\Unreal Projects\Slaves\Binaries\Win64\UE4Editor-Slaves-Win64-DebugGame.pdb
1> Cumulative action seconds (8 processors): 0,00 building projects, 0,12 compiling, 0,00 creating app bundles, 0,00 generating debug info, 0,00 linking, 0,00 other
1> UBT execution time: 4,34 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: Der Befehl ""D:\dev\Unreal Engine 4\Unreal Engine\4.3\Engine\Build\BatchFiles\Build.bat" SlavesEditor Win64 DebugGame "D:\dev\Unreal Projects\Slaves\Slaves.uproject" -rocket" wurde mit dem Code -1 beendet.
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========
It makes no sense to me, maybe someone can help?