Let's talk

GKLCharacter.h

Source/GASKitLite/Public/GKLCharacter.h Raw Download ZIP

Click a line number to link it. Shift-click to select a range.

1// Copyright (c) 2026 Reignance Studios. MIT License, see LICENSE.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "AbilitySystemInterface.h"
7#include "GameFramework/Character.h"
8#include "GameplayTagContainer.h"
9#include "GKLCharacter.generated.h"
10
11class UAbilitySystemComponent;
12
13/**
14 * Character whose abilities live on AGKLPlayerState.
15 *
16 * The ASC needs its avatar set on both machines: the server in PossessedBy, the owning
17 * client in OnRep_PlayerState. Missing the client half is the most common reason
18 * predicted abilities never activate on the client.
19 *
20 * Input binding is not included: call ActivateAbilityByTag from your Enhanced Input events.
21 */
22UCLASS()
23class GASKITLITE_API AGKLCharacter : public ACharacter, public IAbilitySystemInterface
24{
25 GENERATED_BODY()
26
27public:
28 AGKLCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
29
30 virtual void PossessedBy(AController* NewController) override;
31 virtual void OnRep_PlayerState() override;
32 virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
33 virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
34
35 /** Activates every granted ability with this tag (e.g. Ability.Heal). Call it on the owning client to predict. */
36 UFUNCTION(BlueprintCallable, Category = "GASKit Lite")
37 bool ActivateAbilityByTag(FGameplayTag AbilityTag);
38
39 UFUNCTION(BlueprintPure, Category = "GASKit Lite")
40 bool IsDead() const { return bIsDead; }
41
42 /** Server only. Called by the Death ability. */
43 void Die();
44
45protected:
46 /** Runs on the server and on every client. Default: stop movement. */
47 UFUNCTION(BlueprintNativeEvent, Category = "GASKit Lite")
48 void OnDeath();
49 virtual void OnDeath_Implementation();
50
51 UPROPERTY(ReplicatedUsing = OnRep_IsDead, BlueprintReadOnly, Category = "GASKit Lite")
52 bool bIsDead = false;
53
54 UFUNCTION()
55 void OnRep_IsDead();
56
57private:
58 void InitAbilitySystem();
59};

Still desyncing in packaged builds?

Free code fixes one symptom. A Diagnostic finds the cause across your project in two days.