Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fill out your copyright notice in the Description page of Project Settings.
- #pragma once
- #include "GameFramework/Character.h"
- #include "BaseCharacter_C.generated.h"
- UCLASS()
- class FPS2_API ABaseCharacter_C : public ACharacter
- {
- GENERATED_BODY()
- public:
- // Sets default values for this character's properties
- ABaseCharacter_C();
- // 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;
- public:
- //Step 2: Expose a float property
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "BaseCharacter")
- float HealthMax = 100.0f;
- //Step 2: Expose a float property
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "BaseCharacter")
- float Health = 100.0f;
- // Health percentage between 0.0 and 1.0
- UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "BaseCharacter")
- float HealthPerc = 1.0f;
- //Step 3: Expose a boolean property
- UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "BaseCharacter")
- bool IsDead = false;
- //Step 4: Make a helper function, just because we are lazy
- virtual void CalculateDead();
- //Step 5: Expose a method
- UFUNCTION(BlueprintCallable, Category = "BaseCharacter")
- virtual void CalculateHealth(float delta);
- UFUNCTION(BlueprintCallable, Category = "BaseCharacter")
- virtual void Kill();
- //// Create Event
- //UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "When Player Dies")) // Category = "BaseCharacter",
- //virtual void OnDeath();
- //Step 6: Editor code to make updating values in the editor cleaner
- #if WITH_EDITOR
- virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
- #endif
- // Create Event
- UFUNCTION(BlueprintImplementableEvent, Category = "BaseCharacter")
- void OnDeath();
- void OnDeath_Implementation();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement