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"

[C++] How to debug in the constructor

Hey guys

My current problem is i want the purple arrows to point to each other. Essentially I want to show what objects are linked in the viewport, but I'm unsure on 1 thing.

How can I debug the constructor of a class WHILE MY GAME IS NOT PLAYING? My UE_LOGS are not printing, I tried to make the variable visible in the details tab but it seems to be more editable rather than live updating.

any help would be greatly appreciated! test

Product Version: UE 4.21
Tags:
more ▼

asked Nov 07 '18 at 07:19 PM in C++ Programming

avatar image

Kilroymyboy
1 2

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

3 answers: sort voted first

SOLVED:

https://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AActor/PostEditMove/index.html

The problem is I wasn't looking in the right spot, The constructor is only called when the object is compiled or placed into the world. I needed a function that was called EVERY time the object was moved, (much like the constructor in the blueprints).

more ▼

answered Nov 08 '18 at 02:24 AM

avatar image

Kilroymyboy
1 2

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

So do you want the arrows to update rotation in the constructor or do you want a property in the editor to update from the constructor and show its value live? To do that you would have to use post init properties function. Here is a link to the docs, near the top is a section called “setting defaults in my constructor” that talks about this. Let me know if that works.

https://docs.unrealengine.com/en-US/Programming/Introduction

more ▼

answered Nov 07 '18 at 08:42 PM

avatar image

Steve SybrSyn
1.5k 4 5 10

avatar image Kilroymyboy Nov 07 '18 at 11:44 PM

Ideally both, I want the arrow to update rotation in the constructor, but I would like to know the live values of some of the vectors I'm calculating.

For example when moving my object around in the editor I would like to see that angle I'm trying to generate, whether it's in a log or in the details tab.

I'm not sure if the link provided helps, I think I'm already doing that but I'll double check when I get home

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

We can debug on screen like this. Just make the changes to print out your transform, rotation, etc. (will need header #include "Engine.h")

 if (GEngine != NULL) 
 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("Hovering"));

Or in the logs likes this. Next to content browser labeled 'Output Log'

 UE_LOG(LogClass, Log, TEXT("Name: %s"), *FoundActors[i]->GetName());



Hope this helps debugging!

more ▼

answered Nov 08 '18 at 12:01 AM

avatar image

eriksnoww
56 3 3

avatar image Kilroymyboy Nov 08 '18 at 01:10 AM

hmm, this is hard to explain, But i think its not the constructor i want, by doing a bit of research, I think theres a function i need to overwrite called OnConstructor? Since i want this to be called when moving the object in the editor like this

EDIT also looks like theres a virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; anyone seen or used these before?

(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