I have this very simple code that refuses to compile and I have no idea why… The error says:
Missing ‘*’ in Expected a pointer type
If I remove the UFUNCTION(BlueprintCallable, Category = “BlinkerGameState”) line, then everything compiles fine.
I found some other threads with the same mistake but none with a similar case.
.h
#pragma once
#include "GameFramework/GameState.h"
#include "BlinkerGameState.generated.h"
UCLASS()
class BLINKER_API ABlinkerGameState : public AGameState
{
GENERATED_BODY()
public:
//================================
// BLUEPRINT FUNCTIONS
UFUNCTION(BlueprintCallable, Category = "BlinkerGameState")
void SortPlayerStateByScore(TArray<APlayerState>& _PlayersToSort);
//================================
};
.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Blinker.h"
#include "BlinkerGameState.h"
void ABlinkerGameState::SortPlayerStateByScore(TArray<APlayerState>& _PlayersToSort)
{
}
BlueprintCallable don’t allow to have reference in argument, so that is expected pointer for your case, so u can change to this if u want to use BlueprintCallable.
Know this is a bit late, currently you need to use a uparam. Below is just an example setup with a few notes. There are probably some improvements to be made.
So the header example would be:
UFUNCTION(BlueprintCallable, Category = "BlinkerGameState") // If I need to override anything, I will include BlueprintNativeEvent at the start.
void SortPlayerStateByScore(UPARAM(ref) const TArray<APlayerState*>& _PlayersToSort);
And then for the implementation, I’d do:
void ABlinkerGameState ::SortPlayerStateByScore(UPARAM(ref) const TArray<APlayerState*>& _PlayersToSort)
// if using BlueprintNativeEvent this would change to: SortPlayerStateByScore_Implementation...
{
// code to execute here.
}