Title:BaseCharcterh
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Character.h"
#include "BaseCharacter.generated.h"
UCLASS(Blueprintable)
class BOXING_API ABaseCharacter : public ACharacter
{
GENERATED_BODY()
public:
//Make a Health Property
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Base Character")
float Health = 100;
//Make an isDead Property
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Base Character")
bool isDead = false;
//Calculate Death Function {Healper}
virtual void CalculateDead();
//Calculate health Function
UFUNCTION(BlueprintCallable, Category = "Base Charcter")
virtual void CalculateHealth(float delta);
#if WITH_EDITOR
//Editor-Centric Code for Changing Properties
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
public:
// Sets default values for this character's properties
ABaseCharacter();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
};
Title-BaseCharcter.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include “Boxing.h”
#include “BaseCharacter.h”
// Sets default values
ABaseCharacter::ABaseCharacter()
{
// Set this character 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 ABaseCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ABaseCharacter::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
// Called to bind functionality to input
void ABaseCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
}
//Implement CalculateHealth
void ABaseCharcter::CalculateHealth(float Delta)
{
Health ± Delta;
CalculateDead();
}
//Implement CalculateDead
void ABaseCharacter::CalculateDead()
{
if (Health <= 0)
isDead = true;
else
isDead = false;
}
//Implement PostEditChangerProperty
#if WITH_EDITOR
void ABaseCharcter::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
isDead = false;
Health = 100;
Super::PostEditChangeProperty(PropertyChangedEvent);
CalculateDead();
}
#endif
Errors:
Error 1 error C2653: ‘ABaseCharcter’ : is not a class or namespace name D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 38 1 Boxing
Error 2 error C2065: ‘Health’ : undeclared identifier D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 40 1 Boxing
Error 3 error C3861: ‘CalculateDead’: identifier not found D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 41 1 Boxing
Error 4 error C2653: ‘ABaseCharcter’ : is not a class or namespace name D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 54 1 Boxing
Error 5 error C2065: ‘isDead’ : undeclared identifier D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 56 1 Boxing
Error 6 error C2065: ‘Health’ : undeclared identifier D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 57 1 Boxing
Error 7 error C2653: ‘Super’ : is not a class or namespace name D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 58 1 Boxing
Error 8 error C3861: ‘POstEditChangeProperty’: identifier not found D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 58 1 Boxing
Error 9 error C3861: ‘CalculateDead’: identifier not found D:\Boxing 4.9\Source\Boxing\BaseCharacter.cpp 59 1 Boxing
Error 10 error : Failed to produce item: D:\Boxing 4.9\Binaries\Win64\UE4Editor-Boxing-2693.dll D:\Boxing 4.9\Intermediate\ProjectFiles\ERROR Boxing
Error 11 error MSB3073: The command ““D:\Epic Games\4.9\Engine\Build\BatchFiles\Build.bat” BoxingEditor Win64 Development “D:\Boxing 4.9\Boxing.uproject” -rocket -waitmutex” exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 Boxing