I just made a ammo crate from actor class and it compiles good but when I go to my mesh propties it won’t let me click on a mesh it said’s, native components are editable when declared as a property in c++ but i did do that here’s my code if u guys can help me
.h
#include "Core.h"
#include "GameFramework/Actor.h"
#include "pickup.generated.h"
UCLASS()
class HORDE_API Apickup : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
Apickup();
public:
UPROPERTY(editanywhere, Category = "Ammo Crate")
class UBoxComponent *pickupbox;
UPROPERTY(editanywhere, Category = "Ammo Crate")
USceneComponent *pickuproot;
UFUNCTION()
void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UPROPERTY(editanywhere, Category = "Ammo Crate")
int32 count;
UPROPERTY(editanywhere, Category = "Ammo Crate")
UStaticMeshComponent* pickupmesh;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
.cpp
include "pickup.h"
#include "Components/StaticMeshComponent.h"
#include "Components/BoxComponent.h"
#include "hordeCharacter.h"
// Sets default values
Apickup::Apickup()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
pickuproot = CreateDefaultSubobject<USceneComponent>(TEXT("pickuproot"));
RootComponent = pickuproot;
pickupmesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("pickupmesh"));
pickupmesh->AttachToComponent(pickuproot, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
pickupbox = CreateDefaultSubobject<UBoxComponent>(TEXT("pickupbox"));
pickupbox->SetWorldScale3D(FVector(1.0f, 1.0f, 1.0f));
pickupbox->bGenerateOverlapEvents = true;
pickupbox->OnComponentBeginOverlap.AddDynamic(this, &Apickup::OnOverlapBegin);
pickupbox->AttachToComponent(pickuproot, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
count = 90;
}
void Apickup::OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
AhordeCharacter *character = Cast<AhordeCharacter>(OtherActor);
if (character)
{
character->Maxammo = character->Maxammo + count;
this->Destroy();
}
}
// Called when the game starts or when spawned
void Apickup::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void Apickup::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}