1
\$\begingroup\$

I am not entirely new to coding, but I am new to C++. I receive the error below often, but find that it comes due to some sort of syntax error (using a minus sign instead of an equal sign, or misspelling a variable name I've already declared elsewhere), but I can't seem to find what's wrong with my most recent error:

Output Log upon Compile

And here's the code itself:

void ARCCharacter::Raycast()
{
  FHitResult* HitResult = new FHitResult();
  FVector StartTrace = FirstPersonCameraComponent->GetForwardVector();
  FVector EndTrace = (StartTrace* 5000.f) + StartTrace;
  FCollisionQueryParams* CQP = new FCollisionQueryParams();

  if(GetWorld()->LineTraceSingleByChannel(*HitResult, StartTrace, EndTrace, ECC_Visibility, *CQP))
  {

    DrawDebugLine(GetWorld(), StartTrace, EndTrace, FColor(255, 0, 0) true);


    if(HitResult->GetActor() != NULL)
    {
        HitResult->GetActor()->Destroy();
    }

 }

}

Also, I'm following along with a tutorial, so I'm not sure where my code diverges from the teacher's: link. I'm using XCode to work with C++ in the UE4 editor, and while I'm sure there's a simple solution to this problem, I'd like to learn about common errors beginners may encounter so I can understand the language.

\$\endgroup\$
2
  • \$\begingroup\$ The error would be easier to spot if you used a fixed-width font for your errors, as your compiler puts the ^ right below where it found issues. \$\endgroup\$ Commented Jan 25, 2017 at 20:28
  • \$\begingroup\$ And if you look up a little higher in the error log, you'll see it's giving you another error on the same line, probably means line 297, between characters 22 and 75 is worth investigating. Syntax errors and debugging are not specific to game development, so you might seek solutions on stackoverflow, which is targeted at more general development. \$\endgroup\$ Commented Jan 25, 2017 at 20:32

1 Answer 1

0
\$\begingroup\$

I think you're simply missing a comma before true on this line:

DrawDebugLine(GetWorld(), StartTrace, EndTrace, FColor(255, 0, 0) , true);

\$\endgroup\$
3
  • \$\begingroup\$ I think this question is more about better strategies for debugging, instead of what this specific error is (even though your answer is correct). \$\endgroup\$ Commented Jan 25, 2017 at 20:34
  • \$\begingroup\$ It was honestly that simple? I added the comma (I actually remember retyping the line and forgetting to add it) and re-compiled, and it's a success. Thank you so much. Should I delete this question? \$\endgroup\$ Commented Jan 25, 2017 at 20:34
  • \$\begingroup\$ It's that simple. The compiler isn't super smart. It's expecting some syntax and when it's not there, it's doesn't exactly know why it's not there, could be it saw something else before the symbol it was expecting, or the symbol is missing, or something else entirely. You don't have to delete it, but I'm not sure it's very useful for any future visitors. \$\endgroup\$ Commented Jan 25, 2017 at 20:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.