Hallo) I’ve tried to make forward declare, but it doesn’t work.
Here’s changes in the code (There’s normal building without them):
class APickupItem; // forward declare the APickupItem class,
// since it will be "mentioned" in a member function
decl below
…and this’s error message
...\prototip1Character.h(4):fatal error C1083: prototip1Character.generated.h: No such file or directory
...prototip1Character.h(4):fatal error C1083: prototip1Character.generated.h: No such file or directory
Could you please include prototip1Character.h
as that might have a code error in it. The error doesn’t appear to be related to the forward declaration.
Here it is
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Character.h"
#include "prototip1Character.generated.h"
class UInputComponent;
class APickupItem; // forward declare the APickupItem class,
// since it will be "mentioned" in a member function
decl below
UCLASS(config=Game)
class Aprototip1Character : public ACharacter
{
GENERATED_BODY()
TMap<FString, int> Backpack;
TMap<FString, UTexture2D*> Icons;
void Pickup(APickupItem *item);
/** Pawn mesh: 1st person view (arms; seen only by self) */
UPROPERTY(VisibleDefaultsOnly, Category=Mesh)
class USkeletalMeshComponent* Mesh1P;
/** Gun mesh: 1st person view (seen only by self) */
UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
class USkeletalMeshComponent* FP_Gun;
/** Location on gun mesh where projectiles should spawn. */
UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
class USceneComponent* FP_MuzzleLocation;
/** First person camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FirstPersonCameraComponent;
public:
Aprototip1Character();
virtual void BeginPlay();
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
bool inventoryShowing;
/*... Here is some function and variables (they are OK (the code has alredy worked with them))...*/
/** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseTurnRate;
/** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseLookUpRate;
/** Gun muzzle's offset from the characters location */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Gameplay)
FVector GunOffset;
/** Projectile class to spawn */
UPROPERTY(EditDefaultsOnly, Category=Projectile)
TSubclassOf<class Aprototip1Projectile> ProjectileClass;
/** Sound to play each time we fire */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Gameplay)
class USoundBase* FireSound;
/** AnimMontage to play each time we fire */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
class UAnimMontage* FireAnimation;
protected:
/** Fires a projectile. */
void OnFire();
/** Handles moving forward/backward */
void MoveForward(float Val);
/** Handles stafing movement, left and right */
void MoveRight(float Val);
/**
* Called via input to turn at a given rate.
* @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
*/
void TurnAtRate(float Rate);
/**
* Called via input to turn look up/down at a given rate.
* @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
*/
void LookUpAtRate(float Rate);
struct TouchData
{
TouchData() { bIsPressed = false;Location=FVector::ZeroVector;}
bool bIsPressed;
ETouchIndex::Type FingerIndex;
FVector Location;
bool bMoved;
};
void BeginTouch(const ETouchIndex::Type FingerIndex, const FVector Location);
void EndTouch(const ETouchIndex::Type FingerIndex, const FVector Location);
void TouchUpdate(const ETouchIndex::Type FingerIndex, const FVector Location);
TouchData TouchItem;
protected:
// APawn interface
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
// End of APawn interface
/*
* Configures input for touchscreen devices if there is a valid touch interface for doing so
*
* @param InputComponent The input component pointer to bind controls to
* @returns true if touch controls were enabled.
*/
bool EnableTouchscreenMovement(UInputComponent* InputComponent);
public:
/** Returns Mesh1P subobject **/
FORCEINLINE class USkeletalMeshComponent* GetMesh1P() const { return Mesh1P; }
/** Returns FirstPersonCameraComponent subobject **/
FORCEINLINE class UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
};
Hi Volkoshkursk,
The above error is caused by decl below
above the UCLASS
declaration.
Cheers,
I try to edit it
Class 'APickupItem' must inherit UObject or a UObject-derived class prototip1 ...\prototip1Character.h 1
and there’re changes in the code
UCLASS()
class APickupItem; // forward declare the APickupItem class,
// since it will be "mentioned" in a member function
decl below
class Aprototip1Character : public ACharacter
Unfortunately, I don’t understand how to make inheritance
My apologies. I should have been clear. You need to REMOVE the line decl below
above the UCLASS
declaration of Aprototip1Character
as that isn’t valid C++. The location of the UCLASS
declaration was correct previously.