Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Interface Issue:
- The interface works on 2/5 AActors that are directly derived from AActor.
- Error c:\users\####\documents\unreal projects\heistgame\source\heistgame\CP_InventoryItemPickup.h(11) : error C2504: 'ICP_UseInterface': base class undefinedc:\users\####\documents\unreal projects\heistgame\source\heistgame\CP_InventoryItemPickup.h(11): error C2504: 'ICP_UseInterface': base class undefined
- //////////////////////////////////////////////////////////////////////////
- // CP_UseInterface.h //
- //////////////////////////////////////////////////////////////////////////
- #pragma once
- #include "CP_Character.h"
- #include "CP_UseInterface.generated.h"
- UINTERFACE(NotBlueprintable)
- class HEISTGAME_API UCP_UseInterface : public UInterface
- {
- GENERATED_UINTERFACE_BODY()
- };
- class HEISTGAME_API ICP_UseInterface
- {
- GENERATED_IINTERFACE_BODY()
- public:
- UFUNCTION(BlueprintNativeEvent, Category = "_Heist")
- bool InterfactWith(ACP_Character *callingCharacter);
- };
- //////////////////////////////////////////////////////////////////////////
- // CP_LootBag.h // THIS WORKS
- //////////////////////////////////////////////////////////////////////////
- #pragma once
- #include "GameFramework/Actor.h"
- #include "CP_Character.h"
- #include "CP_UseInterface.h"
- #include "CP_LootBag.generated.h"
- UCLASS()
- class HEISTGAME_API ACP_LootBag : public AActor, public ICP_UseInterface
- {
- GENERATED_BODY()
- public:
- ACP_LootBag();
- virtual void BeginPlay() override;
- virtual void Tick( float DeltaSeconds ) override;
- //Remove after testing confirmation and set in const
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- float bagWeight;
- //May not need this at a later date
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- int32 bagValue = 2;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- bool isHeld = false;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- ACP_Character* lastTouchActor;
- virtual bool InterfactWith_Implementation(ACP_Character *callingCharacter) override;
- };
- //////////////////////////////////////////////////////////////////////////
- // CP_LootBag.cpp // THIS WORKS
- //////////////////////////////////////////////////////////////////////////
- #include "HeistGame.h"
- #include "CP_LootBag.h"
- ACP_LootBag::ACP_LootBag()
- {
- bagWeight = 25.f;
- PrimaryActorTick.bCanEverTick = true;
- }
- void ACP_LootBag::BeginPlay()
- {
- Super::BeginPlay();
- }
- void ACP_LootBag::Tick( float DeltaTime )
- {
- Super::Tick( DeltaTime );
- }
- bool ACP_LootBag::InterfactWith_Implementation(ACP_Character *callingCharacter)
- {
- //Loot bag
- if (!callingCharacter->hasBag && !isHeld)
- {
- //Preventing this being called again
- callingCharacter->hasBag = true;
- callingCharacter->heldLootBag = this;
- isHeld = true;
- lastTouchActor = callingCharacter;
- //Set the collision and physics
- SetActorEnableCollision(false);
- Cast<UStaticMeshComponent>(GetRootComponent())->SetSimulatePhysics(false);
- //Attach the item to our socket
- const FAttachmentTransformRules attachmentRules(EAttachmentRule::SnapToTarget, true);
- AttachToComponent(callingCharacter->GetMesh(), attachmentRules, FName("BagBone"));
- return true;
- }
- return false;
- }
- //////////////////////////////////////////////////////////////////////////
- // ACP_InventoryItemPickup.h // THIS DOES NOT WORK
- //////////////////////////////////////////////////////////////////////////
- #pragma once
- #include "GameFramework/Actor.h"
- #include "CP_UseInterface.h"
- #include "CP_InventoryItemPickup.generated.h"
- UCLASS()
- class HEISTGAME_API ACP_InventoryItemPickup : public AActor, public ICP_UseInterface
- {
- GENERATED_BODY()
- public:
- ACP_InventoryItemPickup();
- virtual void BeginPlay() override;
- virtual void Tick( float DeltaSeconds ) override;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- int32 keyID = -1;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- bool isLockpick = false; //if this is a lockpick main item
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- bool isHack = false; //if this is a hack main item
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- bool isCrowbar = false; //if this is a Crowbar main item
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
- FString iconName = "Thief"; //Thief is the default
- virtual bool InterfactWith_Implementation(ACP_Character *callingCharacter) override;
- };
- //////////////////////////////////////////////////////////////////////////
- // ACP_InventoryItemPickup.cpp // THIS DOES NOT WORK
- //////////////////////////////////////////////////////////////////////////
- #include "HeistGame.h"
- #include "CP_InventoryItemPickup.h"
- // Sets default values
- ACP_InventoryItemPickup::ACP_InventoryItemPickup()
- {
- // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
- PrimaryActorTick.bCanEverTick = true;
- }
- // Called when the game starts or when spawned
- void ACP_InventoryItemPickup::BeginPlay()
- {
- Super::BeginPlay();
- }
- // Called every frame
- void ACP_InventoryItemPickup::Tick( float DeltaTime )
- {
- Super::Tick( DeltaTime );
- }
- bool ACP_InventoryItemPickup::InterfactWith_Implementation(ACP_Character *callingCharacter)
- {
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement