Raycasting c++ doesn't work?

  1. if (bombercast) {
  2. if (GEngine) {
  3. GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Red, FString::Printf(TEXT(“Impact Point: %s”), *OutHit.ImpactPoint.ToString()));
  4. }
  5. }
  6. else
  7. {
  8. GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Blue, FString::Printf(TEXT(“Impact Point: %s”), *OutHit.ImpactPoint.ToString()));
  9. }

For some reason, it doesn’t work. The message is always blue. If I get rid of bombercast though, it actually registers actors being hit. Otherwise, it doesn’t. Thanks in advance.

Well, I suppose the quick fix to this problem would be simply omit the bombercast variable. I’m assuming that’s not what you want though; you can use GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Red, bombercast ? “true” : “false”) to see what the value of bombercast is at a certain point. From there you can check and see why bombercast isn’t true/when it becomes false.

“bombercast” is definitely null somewhere. Please post some more code pertaining to bombercast and how it’s set.

I’d also consider using breakpoints instead of having to deal with including GameEngine in every class you want to print. If you don’t need the information and are just checking if something goes through, breakpoints are a much faster iterative tool as you don’t need to compile every time you add/edit a print.