x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Unreal Engine 4.22.2 crashes after adding C++ code.

Hello Everyone,

I have recently started using UE4 and I have an issue. I am attempting to get an object name from an object in my level. I have created a class that reports the name of the object in the LOG. I then add the class as a component of one of the chairs in the basic project template. The code is as follows

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

include "PositionReporter.h"

include "GameFramework/Actor.h"

// Sets default values for this component's properties UPositionReporter::UPositionReporter() { // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features // off to improve performance if you don't need them.

}

// Called when the game starts void UPositionReporter::BeginPlay() { Super::BeginPlay();

 // If I comment out the line below my code runs fine
 FString ObjectName = GetOwner()->GetName();
 UE_LOG(LogTemp, Warning, TEXT("Position Reporter Active"));

}

// Called every frame void UPositionReporter::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

 // ...

}

This is the information from the Crash Reporter Unhandled exception

UE4Editor_Engine UE4Editor_Escape_Demo_2980!UPositionReporter::UPositionReporter() [C:\Users\developer\Documents\Unreal Projects\Escape_Demo\Source\Escape_Demo\PositionReporter.cpp:13] UE4Editor_CoreUObject UE4Editor_CoreUObject UE4Editor_CoreUObject UE4Editor_CoreUObject UE4Editor_Core UE4Editor_Core UE4Editor_Projects UE4Editor_Projects UE4Editor UE4Editor UE4Editor UE4Editor UE4Editor UE4Editor kernel32 ntdll

Product Version: UE 4.22
Tags:
more ▼

asked May 22 '19 at 07:05 AM in Using UE4

avatar image

w_nicholas
1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You GetOwner() Function's return value may be NULL.

more ▼

answered May 23 '19 at 05:40 AM

avatar image

正义使者
11 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question