some small changes

This commit is contained in:
Caleb Buhungiro
2025-06-19 10:19:34 +08:00
parent accf4cce15
commit b8475c7ba1
12 changed files with 24 additions and 24 deletions

View File

@@ -14,6 +14,10 @@ ACCharacter::ACCharacter()
CAbilitySystemComponent = CreateDefaultSubobject<UCAbilitySystemComponent>(TEXT("Ability System Component"));
CAttributeSet = CreateDefaultSubobject<UCAttributeSet>(TEXT("CAttribute Set"));
/**
* This is also valid
* CAttributeSet = CAbilitySystemComponent->GetSet<UCAttributeSet>();
**/
}
void ACCharacter::ServerSideInit()

View File

@@ -1,4 +1,4 @@
// Multipalyer By Caleb
// Multiplayer By Caleb
#include "Crunch/Public/Player/CPlayerController.h"
@@ -8,8 +8,7 @@
void ACPlayerController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
CPlayerCharacter = Cast<ACPlayerCharacter>(InPawn);
if (CPlayerCharacter)
if (CPlayerCharacter = Cast<ACPlayerCharacter>(InPawn); IsValid(CPlayerCharacter))
{
CPlayerCharacter->ServerSideInit();
}
@@ -18,8 +17,7 @@ void ACPlayerController::OnPossess(APawn* InPawn)
void ACPlayerController::AcknowledgePossession(class APawn* P)
{
Super::AcknowledgePossession(P);
CPlayerCharacter = Cast<ACPlayerCharacter>(P);
if (CPlayerCharacter)
if (CPlayerCharacter = Cast<ACPlayerCharacter>(P); IsValid(CPlayerCharacter))
{
CPlayerCharacter->ClientSideInit();
}

View File

@@ -7,6 +7,9 @@
#include "GameFramework/Character.h"
#include "CCharacter.generated.h"
class UCAbilitySystemComponent;
class UCAttributeSet;
UCLASS()
class CRUNCH_API ACCharacter : public ACharacter, public IAbilitySystemInterface
{
@@ -24,7 +27,7 @@ public:
private:
UPROPERTY(EditDefaultsOnly, Category="Gameplay Effects")
class UCAbilitySystemComponent* CAbilitySystemComponent;
UPROPERTY()
class UCAttributeSet* CAttributeSet;
UCAbilitySystemComponent* CAbilitySystemComponent;
UPROPERTY(BlueprintReadOnly, Category="Gameplay Effects", meta=(AllowPrivateAccess=true))
const UCAttributeSet* CAttributeSet;
};

View File

@@ -7,7 +7,6 @@
#include "CAbilitySystemComponent.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class CRUNCH_API UCAbilitySystemComponent : public UAbilitySystemComponent
{

View File

@@ -7,7 +7,6 @@
#include "AttributeSet.h"
#include "CAttributeSet.generated.h"
/**
* This defines a set of helper functions for accessing and initializing attributes, to avoid having to manually write these functions.
* It would creates the following functions, for attribute Health

View File

@@ -6,9 +6,6 @@
#include "GameFramework/GameModeBase.h"
#include "CGameMode.generated.h"
/**
*
*/
UCLASS()
class CRUNCH_API ACGameMode : public AGameModeBase
{

View File

@@ -13,7 +13,7 @@ class CRUNCH_API ACPlayerController : public APlayerController
public:
virtual void OnPossess(APawn* InPawn) override;
virtual void AcknowledgePossession(class APawn* P) override;
virtual void AcknowledgePossession(APawn* P) override;
private:
UPROPERTY()