Unreal Crashes Whenever I try logging from Ray Casting

So im at section 3 (building escape) lecture 86 (archived course) where ben is using raycasting to determine the name of what is in front of him. I finished the challenge at the end and was so glad I did the same thing ben did to log the object name to the console.

here the thing though, whenever I compile and run Unreal Crashes every time but if I remove the UE_LOG line I highlighted in the screen shot, it works without issue, what’s up with that?

Just going to give a small hint: Those red lines are telling you that there’s something not quite right. While, there are times when it can work fine despite that, the rest of the time will result in crashes or perhaps other problems.

You want to see what the error is for each line but for the context of what you say here, you want to see the one there with UE_LOG. It will tell you what’s wrong. You can try moving the mouse pointer over top of it.

hi @QueueButton,

I know that something isn’t right from the red squiggly lines, but visual studio code doesn’t seem to want work properly for me. I even tried asking on the forums just like this question

but no one tried helping me out :sweat_smile:

anyways I tried hovering over UE_LOG this is what I got,

“Pointer to an incomplete class type not allowed” :joy: incomplete class?

I also tried hovering of the ray cast function and got this

Both of those problems may stem from missing or incorrect header use or even incorrect code when defining the class in the header or whatever.

If you have the same exact code with 0 errors (differences) as their code on github https://github.com/UnrealCourse then its probably a result of VSC not configured correctly or something with UE.

But, I have a feeling you have something slightly incorrect with the code.

A) You can always create a new project in VS (or use Xcode or whatever) and all the classes then copy/paste the code over and see if it works then or not.

B) You can also quickly compare two files (eg grab the gitgub raw and save it on the Mac and compare with yours http://osxdaily.com/2018/02/06/use-diff-compare-files-command-line-mac/ to check for all differences.

C) You can post the code for the cpp and h here for others to check for you.

Because you’re always derefenecing Hit.GetActor(). What if Hit.GetActor() returns nullptr? You need to add a check before doing that.

Yeah it worked, thanks for the help @DanM @QueueButton

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms