Download

UE_LOG and AddOnScreenDebugMessage doesn't work in my case

Hi, i made my custom actor based class Steam_Function_actor_based, inside it i made a method UE_RequestLobbyList()

Steam_Function_actor_based.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include “GameFramework/Actor.h”
#include “Steam_Function_actor_based.generated.h”

UCLASS()
class STEAM_TRAINING_API ASteam_Function_actor_based : public AActor
{
GENERATED_BODY()

public:
// Sets default values for this actor’s properties
ASteam_Function_actor_based();

// Called when the game starts or when spawned
virtual void BeginPlay() override;

// Called every frame
virtual void Tick( float DeltaSeconds ) override;

UFUNCTION(BlueprintCallable, Category = "Steam")
void UE_RequestLobbyList();

};

and made method body in Steam_Function_actor_based.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include “steam_training.h”
#include “Steam_Function_actor_based.h”
#include “steam_api.h”

#pragma comment(lib, “steam_api64.lib”)

void ASteam_Function_actor_based::UE_RequestLobbyList()
{
UE_LOG(LogTemp, Warning, TEXT(“hSteamAPICall”));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT(“hSteamAPICall”));

SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList();
//SteamAPI_SetMiniDumpComment("Minidump comment: SteamworksExample.exe

");
//SteamAPI_WriteMiniDump(1, 0, 0);

UE_LOG(LogTemp, Warning, TEXT("hSteamAPICall is %d"), hSteamAPICall);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("hSteamAPICall is %d"), hSteamAPICall));

}

so when i call my method from blueprint, execution lines show method called https://yadi.sk/i/U1bZIsPfgSD9J , but no onscreen message and no log message, why? i also tryed call my method in other way - by casting after jump and casting fail (target variable just empty)

after added bool return result to my method i started getting errors in UE log

LogScript:Warning: Accessed None ‘target’
SideScrollerCharacter_C /Game/SideScrollerBP/Maps/UEDPIE_0_SideScrollerExampleMap.SideScrollerExampleMap:PersistentLevel.SideScrollerCharacter_C_0
Function /Game/SideScrollerBP/Blueprints/SideScrollerCharacter.SideScrollerCharacter_C:ExecuteUbergraph_SideScrollerCharacter:0060
PIE:Error: Error Accessed None ‘target’ from node Construction Script in blueprint SideScrollerCharacter

any ideas what wrong?

I don’t know if this is the cause of the problem, but don’t you have to include “Engine.h” to use AddOnScreenDebugMessage?

tryed

#include “Engine.h”

in Steam_Function_actor_based.cpp

didn’t help, still same error in log

LogScript:Warning: Accessed None ‘target’
SideScrollerCharacter_C /Game/SideScrollerBP/Maps/UEDPIE_0_SideScrollerExampleMap.SideScrollerExampleMap:PersistentLevel.SideScrollerCharacter_C_0
Function /Game/SideScrollerBP/Blueprints/SideScrollerCharacter.SideScrollerCharacter_C:ExecuteUbergraph_SideScrollerCharacter:009B
PIE:Error: Error Accessed None ‘target’ from node Construction Script in blueprint SideScrollerCharacter

seems this LogScript:Warning: Accessed None ‘target’ error disappears with removing return bool value on my method, but 2 log messages still doesn’t apper, any ideas?

investigated interesting thing - Print String from blueprints work fine, but

UE_LOG(LogTemp, Warning, TEXT(“hSteamAPICall”));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT(“hSteamAPICall”));

from my custom method won’t at all, but i call Print String after my method in blueprint graph, so still no ideas?

to be clear, i use 4.7.6 UE version

also interesting thing, this message should crash app, but it doesn’t!

UE_LOG(LogTemp, Fatal, TEXT(“This fringe case was reached! Debug this!”));

futher investigation lead me to https://www.youtube.com/watch?t=1543&v=t-7JYG9rvWM, i added

DEFINE_LOG_CATEGORY(MyLog); //into my class .cpp

also added

DECLARE_LOG_CATEGORY_EXTERN(MyLog, Log, All); //into my class .h

made blueprint built from my class actor and added that new blueprint into blueprint SideScrollerCharacter that drive your character by default

after debug -> run new instance in VS i could get in output log my message

MyLog:Warning: hSteamAPICall****************************************************

and seems it appeared on screen, but i also got back return bool value and error

LogVoice:Warning: Failed to initialize voice interface
LogScript:Warning: Accessed None ‘target’
SideScrollerExampleMap_C /Game/SideScrollerBP/Maps/UEDPIE_0_SideScrollerExampleMap.SideScrollerExampleMap:PersistentLevel.SideScrollerExampleMap_C_2
Function /Game/SideScrollerBP/Maps/SideScrollerExampleMap.SideScrollerExampleMap_C:ExecuteUbergraph_SideScrollerExampleMap:001F
PIE:Error: Error Accessed None ‘target’ from node Event Begin Play in blueprint SideScrollerExampleMap

so do you have any idea why this PIE:Error: happen?

checked one more thing, seems there’s no need in MyLog category, but! to work UE editor must be run as debugging new instance right in VS, don’t know how it affect UE editor, but after this logs started working!