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"

Log Message not printed

Sir I wrote this code for printing on log screen UE_LOG(LogTemp,Warning,TEXT("Yellow Text")); It Is Not Giving Any Errors But Nothing Gets Printed on LogOutput

Product Version: UE 4.11
Tags:
more ▼

asked Sep 15 '16 at 04:44 PM in C++ Programming

avatar image

Anagh
1 1 2 1

avatar image Doug E ♦♦ STAFF Sep 15 '16 at 05:09 PM

Hey Anagh-

Where exactly are you checking your logs for your message? I copied the code you provided into an actor tick function and got the LogTemp warning printed to the output log during PIE. Can you explain exactly what you're doing?

avatar image Anagh Sep 15 '16 at 05:19 PM

I Wrote This Code In Begin Play() Is it Wrong????

avatar image Doug E ♦♦ STAFF Sep 15 '16 at 05:52 PM

Are you looking at the output log in the editor after pressing play? Even in BeginPlay() the warning message is appearing in my project.

avatar image Anagh Sep 15 '16 at 06:01 PM

Yes I Was Looking At The Output Log In The Editor The Warning Message is Still Not Showing

avatar image fallingbrickwork Sep 15 '16 at 06:30 PM

Do you actually have this code in the scene... i.e. if it's a class that extends Actor, have you actually dragged the Actor into your map, or if it's an ActorComponent is it on another Actor?

How have you got things setup?

avatar image Anagh Sep 16 '16 at 05:53 AM

Actually I am New to Unreal Engine So Can U Please Tell Stepwise Procedure To Follow

avatar image fallingbrickwork Sep 16 '16 at 06:49 AM

I can't directly as I don't know what base class you are extending from. Has the code been added to existing code? Is it a new class you have created? etc

As a test you could create a new C++ class in the ContentBrowser, choose to extend from Actor. Then drag this from the ContentBrowser into your scene. Then open the C++ code and add the UE_LOG line into the ::BeginPlay() function.

avatar image Anagh Sep 16 '16 at 07:05 AM

I Created A New C++ Class Named PositionReport2 Chose Actor class In The C++ Code Added the UE_LOG line but when i drag this from content browser to my scene The Engine Crashes

avatar image fallingbrickwork Sep 16 '16 at 07:19 AM

This should work fine, if the engine is crashing i'm guess it is something else within the project. I did a quick test, see images...alt textalt text

1.png (316.3 kB)
2.png (159.1 kB)
avatar image Anagh Sep 16 '16 at 08:07 AM

Thanks I Solved that Problem Do We Have to Drag Everytime Before We play to Get Yellow text????

and i wrote this code for determining position but its not showing on output log

 FString ObjectName = GetOwner()->GetName();
 FString ObjectPos = GetOwner()->GetTransform().GetLocation().ToString();

 UE_LOG(LogTemp, Warning, TEXT("%s is at %s"), *ObjectName, *ObjectPos);

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

1 answer: sort voted first

This class is extending the AActor class which has all the functionality required to get the Transform etc, so you can probably use the 'this' keywork instead of GetOwner().

try something like:

 FString ObjectName = this->GetName();
     FString ObjectPos = this->GetTransform().GetLocation().ToString();
     UE_LOG(LogTemp, Warning, TEXT("%s is at %s"), *ObjectName, *ObjectPos);

Infact, you probably don't even need the 'this->' before GetName() and GetTransform().

No, you shouldn't need to drag it in each time. Once it's in your map and it's saved it should always be there, unless you are instantiating it at runtime, in which case it'll still be there and BeginPlay() will still be called.

more ▼

answered Sep 16 '16 at 08:26 AM

avatar image

fallingbrickwork
35 6 10 14

avatar image Anagh Sep 16 '16 at 09:36 AM

Thanks ..What is The Difference Between This and GetOwner()??? Whenever I Use Getowner() the Engine Crashes while in Your code It worked nicely Is there Any Reason To That???? And In The Log Output It Is Always Showing X=0,Y=0,Z=0,How To Change That????

avatar image CriErr Sep 16 '16 at 09:55 AM

this* is pointer to "Self" while GetOwner() return pointer to owner, which might be nullptr if you not specified owner on actor spawning to level.

avatar image fallingbrickwork Sep 16 '16 at 10:26 AM

0,0,0 is the Actor's position within your map (this is what you wanted to output).

Select the Actor in WorldOutliner and lookat the Transform section of the details panel... is it at 0,0,0?? Try dragging it to a new location and playing again.

avatar image Anagh Sep 16 '16 at 10:47 AM

Actually Whenever I Drag It Goes To Some Position I Dont Know and When I Click Play It Says X=0 Y=0 Z=0, What I wanna Do Is Whenever I select any Object (for example chair) it shows me the position of it

(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