Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. Interface Issue:
  2.  
  3. The interface works on 2/5 AActors that are directly derived from AActor.
  4.  
  5. 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
  6.  
  7.  
  8. //////////////////////////////////////////////////////////////////////////
  9. // CP_UseInterface.h //
  10. //////////////////////////////////////////////////////////////////////////
  11.  
  12.  
  13. #pragma once
  14.  
  15. #include "CP_Character.h"
  16. #include "CP_UseInterface.generated.h"
  17.  
  18. UINTERFACE(NotBlueprintable)
  19. class HEISTGAME_API UCP_UseInterface : public UInterface
  20. {
  21.  
  22. GENERATED_UINTERFACE_BODY()
  23.  
  24. };
  25.  
  26. class HEISTGAME_API ICP_UseInterface
  27. {
  28.  
  29. GENERATED_IINTERFACE_BODY()
  30.  
  31. public:
  32.  
  33. UFUNCTION(BlueprintNativeEvent, Category = "_Heist")
  34. bool InterfactWith(ACP_Character *callingCharacter);
  35.  
  36. };
  37.  
  38. //////////////////////////////////////////////////////////////////////////
  39. // CP_LootBag.h // THIS WORKS
  40. //////////////////////////////////////////////////////////////////////////
  41.  
  42. #pragma once
  43.  
  44. #include "GameFramework/Actor.h"
  45. #include "CP_Character.h"
  46. #include "CP_UseInterface.h"
  47. #include "CP_LootBag.generated.h"
  48.  
  49. UCLASS()
  50. class HEISTGAME_API ACP_LootBag : public AActor, public ICP_UseInterface
  51. {
  52. GENERATED_BODY()
  53.  
  54. public:
  55.  
  56. ACP_LootBag();
  57. virtual void BeginPlay() override;
  58. virtual void Tick( float DeltaSeconds ) override;
  59.  
  60. //Remove after testing confirmation and set in const
  61. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  62. float bagWeight;
  63.  
  64. //May not need this at a later date
  65. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  66. int32 bagValue = 2;
  67.  
  68. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  69. bool isHeld = false;
  70.  
  71. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  72. ACP_Character* lastTouchActor;
  73.  
  74. virtual bool InterfactWith_Implementation(ACP_Character *callingCharacter) override;
  75.  
  76. };
  77.  
  78. //////////////////////////////////////////////////////////////////////////
  79. // CP_LootBag.cpp // THIS WORKS
  80. //////////////////////////////////////////////////////////////////////////
  81.  
  82. #include "HeistGame.h"
  83. #include "CP_LootBag.h"
  84.  
  85. ACP_LootBag::ACP_LootBag()
  86. {
  87.  
  88. bagWeight = 25.f;
  89. PrimaryActorTick.bCanEverTick = true;
  90.  
  91. }
  92.  
  93. void ACP_LootBag::BeginPlay()
  94. {
  95. Super::BeginPlay();
  96.  
  97. }
  98.  
  99. void ACP_LootBag::Tick( float DeltaTime )
  100. {
  101. Super::Tick( DeltaTime );
  102.  
  103. }
  104.  
  105. bool ACP_LootBag::InterfactWith_Implementation(ACP_Character *callingCharacter)
  106. {
  107.  
  108. //Loot bag
  109. if (!callingCharacter->hasBag && !isHeld)
  110. {
  111.  
  112. //Preventing this being called again
  113. callingCharacter->hasBag = true;
  114. callingCharacter->heldLootBag = this;
  115. isHeld = true;
  116. lastTouchActor = callingCharacter;
  117.  
  118. //Set the collision and physics
  119. SetActorEnableCollision(false);
  120. Cast<UStaticMeshComponent>(GetRootComponent())->SetSimulatePhysics(false);
  121.  
  122. //Attach the item to our socket
  123. const FAttachmentTransformRules attachmentRules(EAttachmentRule::SnapToTarget, true);
  124. AttachToComponent(callingCharacter->GetMesh(), attachmentRules, FName("BagBone"));
  125.  
  126. return true;
  127.  
  128. }
  129.  
  130. return false;
  131.  
  132. }
  133.  
  134. //////////////////////////////////////////////////////////////////////////
  135. // ACP_InventoryItemPickup.h // THIS DOES NOT WORK
  136. //////////////////////////////////////////////////////////////////////////
  137.  
  138. #pragma once
  139.  
  140. #include "GameFramework/Actor.h"
  141. #include "CP_UseInterface.h"
  142. #include "CP_InventoryItemPickup.generated.h"
  143.  
  144. UCLASS()
  145. class HEISTGAME_API ACP_InventoryItemPickup : public AActor, public ICP_UseInterface
  146. {
  147. GENERATED_BODY()
  148.  
  149. public:
  150.  
  151. ACP_InventoryItemPickup();
  152. virtual void BeginPlay() override;
  153. virtual void Tick( float DeltaSeconds ) override;
  154.  
  155. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  156. int32 keyID = -1;
  157.  
  158. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  159. bool isLockpick = false; //if this is a lockpick main item
  160.  
  161. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  162. bool isHack = false; //if this is a hack main item
  163.  
  164. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  165. bool isCrowbar = false; //if this is a Crowbar main item
  166.  
  167. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "_Heist")
  168. FString iconName = "Thief"; //Thief is the default
  169.  
  170. virtual bool InterfactWith_Implementation(ACP_Character *callingCharacter) override;
  171.  
  172. };
  173.  
  174. //////////////////////////////////////////////////////////////////////////
  175. // ACP_InventoryItemPickup.cpp // THIS DOES NOT WORK
  176. //////////////////////////////////////////////////////////////////////////
  177.  
  178. #include "HeistGame.h"
  179. #include "CP_InventoryItemPickup.h"
  180.  
  181. // Sets default values
  182. ACP_InventoryItemPickup::ACP_InventoryItemPickup()
  183. {
  184. // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
  185. PrimaryActorTick.bCanEverTick = true;
  186.  
  187. }
  188.  
  189. // Called when the game starts or when spawned
  190. void ACP_InventoryItemPickup::BeginPlay()
  191. {
  192. Super::BeginPlay();
  193.  
  194. }
  195.  
  196. // Called every frame
  197. void ACP_InventoryItemPickup::Tick( float DeltaTime )
  198. {
  199. Super::Tick( DeltaTime );
  200.  
  201. }
  202.  
  203. bool ACP_InventoryItemPickup::InterfactWith_Implementation(ACP_Character *callingCharacter)
  204. {
  205.  
  206. return false;
  207.  
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement