Hi all,
I have a bit of a convoluted method for communicating with my player state in my networking project which includes a series of Blueprint interface message passes (from actor collison box ->serverside controller->playerstate->clientside controller->hud). I’m sure there is a better way of doing this but its what i have working so far for my other function calls. However, one of my c++ functions which comes from a subobject in my player state crashes when it is called, but only after i have had several dozen interface calls.
I’ve tracked the start of the crash all the way to the actual c++ function call from my playerstate blueprint.
void UMyAttributes::SetAttribute(EAttributesEnum Attribute, uint8 newAbilityScore, bool bIsBase)
{
UE_LOG(LogTemp, Display, TEXT("Start"));
if (MyAttributes.IsValidIndex(0)&&newAbilityScore)
{
TArray<FAttributes> ModifiedAttribute = MyAttributes;
ModifiedAttribute[GetAttributeIndex(Attribute)].AbilityScore = newAbilityScore;
ModifiedAttribute[GetAttributeIndex(Attribute)].AbilityModifier = floor(((((float)newAbilityScore) - 10) / 2));
bIsBase ? MyAttributes = ModifiedAttribute : MyAttributes_Temp = ModifiedAttribute;
UE_LOG(LogTemp, Display, TEXT("End"));
}
}
The crash happens before the UE_LOG writes “Start”, but after the node in blueprints right before this function call.
UCLASS(Blueprintable)
class TOPDOWN_API UMyAttributes : public UObject
{
GENERATED_BODY()
public:
UMyAttributes();
.
.
.
UFUNCTION(BlueprintCallable, Category = "Attributes")
void SetAttribute(EAttributesEnum Attribute, uint8 newAbilityScore, bool bIsBase);
}
UCLASS()
class TOPDOWN_API AMyPlayerState : public APlayerState
{
GENERATED_BODY()
public:
AMyPlayerState(const FObjectInitializer& ObjectInitializer);
protected:
UMyAttributes* Abilities;
}
AMyPlayerState::AMyPlayerState(const FObjectInitializer& ObjectInitializer) {
//Abilities
Abilities = ObjectInitializer.CreateDefaultSubobject<UMyAttributes>(this, TEXT("ABILITIES"));
}
In my playerstate i make it to the print: