Hello, guys so out of nowhere after creating a new DataTable I started getting this error when compiling does anyone know why this could happen? I Tried going into the class it’s pointing to which is a class that is made by unreal engine and the ‘;’ symbol was there
Error code: syntax error: ‘UDataTable’ should be preceded by ‘;’ missing type specifier - int assumed. Note: c++ does not support default - int
Weapon.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Weapon.h"
AWeapon::AWeapon() :
ThrowWeaponTime(0.7f),
bFalling(false),
Ammo(30),
MagazineCapacity(30),
WeaponType(EWeaponType::EWT_SubmachineGun),
AmmoType(EAmmoType::EAT_9mm),
ReloadMontageSection(FName(TEXT("Reload SMG"))),
ClipBoneName(TEXT("smg_clip"))
{
PrimaryActorTick.bCanEverTick = true;
}
void AWeapon::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Keep the Weapon upright
if (GetItemState() == EItemState::EIS_Falling && bFalling)
{
const FRotator MeshRotation{ 0.f, GetItemMesh()->GetComponentRotation().Yaw, 0.f };
GetItemMesh()->SetWorldRotation(MeshRotation, false, nullptr, ETeleportType::TeleportPhysics);
}
}
void AWeapon::ThrowWeapon()
{
FRotator MeshRotation{ 0.f, GetItemMesh()->GetComponentRotation().Yaw, 0.f };
GetItemMesh()->SetWorldRotation(MeshRotation, false, nullptr, ETeleportType::TeleportPhysics);
const FVector MeshForward{ GetItemMesh()->GetForwardVector() };
const FVector MeshRight{ GetItemMesh()->GetRightVector() };
// Direction in which we throw the Weapon
FVector ImpulseDirection = MeshRight.RotateAngleAxis(-20.f, MeshForward);
float RandomRotation{ 30.f };
ImpulseDirection = ImpulseDirection.RotateAngleAxis(RandomRotation, FVector(0.f, 0.f, 1.f));
ImpulseDirection *= 20'000.f;
GetItemMesh()->AddImpulse(ImpulseDirection);
bFalling = true;
GetWorldTimerManager().SetTimer(
ThrowWeaponTimer,
this,
&AWeapon::StopFalling,
ThrowWeaponTime);
EnableGlowMaterial();
}
void AWeapon::StopFalling()
{
bFalling = false;
SetItemState(EItemState::EIS_Pickup);
StartPulseTimer();
}
void AWeapon::OnConstruction(const FTransform& Transform)
{
const FString WeaponTablePath{ TEXT("DataTable'/Game/_Game/DataTable/WeaponDataTable.WeaponDataTable'") };
UDataTable* WeaponTableObject = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), nullptr, *WeaponTablePath));
if (WeaponTableObject)
{
FWeaponDataTable* WeaponDataRow = nullptr;
switch (WeaponType)
{
case EWeaponType::EWT_SubmachineGun:
WeaponDataRow = WeaponTableObject->FindRow<FWeaponDataTable>(FName("SubmachineGun"), TEXT(""));
break;
case EWeaponType::EWT_AssaultRifle:
WeaponDataRow = WeaponTableObject->FindRow<FWeaponDataTable>(FName("AssaultRifle"), TEXT(""));
break;
}
if (WeaponDataRow)
{
AmmoType = WeaponDataRow->AmmoType;
Ammo = WeaponDataRow->WeaponAmmo;
MagazineCapacity = WeaponDataRow->MagazingCapacity;
SetPickupSound(WeaponDataRow->PickupSound);
SetEquipSound(WeaponDataRow->EquipSound);
GetItemMesh()->SetSkeletalMesh(WeaponDataRow->ItemMesh);
SetItemName(WeaponDataRow->ItemName);
SetIconItem(WeaponDataRow->InventoryIcon);
SetAmmoIcon(WeaponDataRow->AmmoIcon);
}
}
}
void AWeapon::DecrementAmmo()
{
if (Ammo - 1 <= 0)
{
Ammo = 0;
}
else
{
--Ammo;
}
}
void AWeapon::ReloadAmmo(int32 Amount)
{
checkf(Ammo + Amount <= MagazineCapacity, TEXT("Attempted to reload with more than magazine capacity!"));
Ammo += Amount;
}
bool AWeapon::ClipIsFull()
{
return Ammo >= MagazineCapacity;
}
Weapon.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Item.h"
#include "AmmoType.h"
#include "Engine/DataTable.h"
#include "WeaponType.h"
#include "Weapon.generated.h"
USTRUCT(BlueprintType)
struct FWeaponDataTable : public FTableRowBase
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EAmmoType AmmoType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 WeaponAmmo;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 MagazingCapacity;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class USoundCue* PickupSound;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
USoundCue* EquipSound;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
USkeletalMesh* ItemMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString ItemName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UTexture2D* InventoryIcon;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UTexture2D* AmmoIcon;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UMaterialInstance* MaterialInstance;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 MaterialIndex;
};
/**
*
*/
UCLASS()
class ZOMBIESHOOTER_API AWeapon : public AItem
{
GENERATED_BODY()
public:
AWeapon();
virtual void Tick(float DeltaTime) override;
protected:
void StopFalling();
virtual void OnConstruction(const FTransform& Transform) override;
private:
FTimerHandle ThrowWeaponTimer;
float ThrowWeaponTime;
bool bFalling;
/** Ammo count for this Weapon */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true"))
int32 Ammo;
/** Maximum ammo that our weapon can hold */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true"))
int32 MagazineCapacity;
/** The type of weapon */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true"))
EWeaponType WeaponType;
/** The type of ammo for this weapon */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true"))
EAmmoType AmmoType;
/** FName for the Reload Montage Section */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true"))
FName ReloadMontageSection;
/** True when moving the clip while reloading */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true"))
bool bMovingClip;
/** Name for the clip bone */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true"))
FName ClipBoneName;
/** Data table for weapon properties */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true"))
UDataTable* WeaponDataTable;
int32 PreviousMaterialIndex;
public:
/** Adds an impulse to the Weapon */
void ThrowWeapon();
FORCEINLINE int32 GetAmmo() const { return Ammo; }
FORCEINLINE int32 GetMagazineCapacity() const { return MagazineCapacity; }
/** Called from Character class when firing Weapon */
void DecrementAmmo();
FORCEINLINE EWeaponType GetWeaponType() const { return WeaponType; }
FORCEINLINE EAmmoType GetAmmoType() const { return AmmoType; }
FORCEINLINE FName GetReloadMontageSection() const { return ReloadMontageSection; }
FORCEINLINE FName GetClipBoneName() const { return ClipBoneName; }
void ReloadAmmo(int32 Amount);
FORCEINLINE void SetMovingClip(bool Move) { bMovingClip = Move; }
bool ClipIsFull();
};
WeaponType.h
#pragma once
UENUM(BlueprintType)
enum class EWeaponType : uint8
{
EWT_SubmachineGun UMETA(DisplayName = "SubmachineGun"),
EWT_AssaultRifle UMETA(DisplayName = "AssaultRifle"),
EWT_MAX UMETA(DisplayName = "DefaultMAX")
};
Above is all the code that i touched before the error