Announcement

Collapse
No announcement yet.

Line Trace Crash

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Line Trace Crash

    I'm a bit frustrated trying to figure this out, so maybe someone here can help.

    I'm working on my sidescroller character. I want to shoot a trace from it 100 x in front of it.

    If I just call the trace, it will return itself as the hit actor.

    if I try to use AddIgnoredActor(this) or any variant that ignores itself, it crashes in the editor when the line of code runs. Any ideas as to why this is happening?

    Here is the sample code:

    Code:
                    const FRotator Rotation = Mesh->GetComponentRotation();
    		FHitResult Hit;
    		FCollisionQueryParams QueryParams;
    		QueryParams.bTraceComplex = false;
    		QueryParams.bTraceAsyncScene = true;
    		QueryParams.bReturnPhysicalMaterial = false;
    		QueryParams.AddIgnoredActor(Controller->GetPawn()); //There is no crash if this line is not here.
    
    		GetWorld()->LineTraceSingle(Hit, GetActorLocation(), FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y) * 100, ECollisionChannel::ECC_WorldStatic, QueryParams);
    		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, Hit.Actor->GetName());
    
    		if (Hit.GetActor() && Hit.GetActor()->ActorHasTag("Wall"))
    		{
    			CharacterMovement->Velocity.Z = CharacterMovement->JumpZVelocity;
    			return false;
    		}
    Last edited by raybarrera; 05-13-2014, 03:47 AM. Reason: fixed title

    #2
    try put the trace in a custom event that fires off away from tick execution line.
    I don't know how this means in C++, but in blueprint, if your line trace hits nothing while on OnTick event execution line, it will hang the controls(except custom action buttons since they fire off tick line).
    Unreal Engine 4 Game Framework diagram for relation of all major base object types
    Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
    Resident Evil Classic Camera
    RPCs official document, Must Read
    Everything you should know about replication

    Comment


      #3
      The constructor for FCollisionQueryParams takes an actor that will be ignored.

      Code:
      FCollisionQueryParams QueryParams(FName(TEXT("MyTrace")), true, this);
      The last argument to that constructor is the actor you wish to ignore. Pass in (this) to refer to the calling class.

      You could probably also just do this:

      Code:
      QueryParams.AddIgnoredActor(this);
      Last edited by smugly12; 05-13-2014, 02:24 PM.

      Comment


        #4
        Originally posted by b1nary View Post
        The constructor for FCollisionQueryParams takes an actor that will be ignored.

        Code:
        FCollisionQueryParams QueryParams(FName(TEXT("MyTrace")), true, this);
        The last argument to that constructor is the actor you wish to ignore. Pass in (this) to refer to the calling class.

        You could probably also just do this:

        Code:
        QueryParams.AddIgnoredActor(this);
        Both cause a crash for me.

        Comment


          #5
          Originally posted by raybarrera View Post
          Both cause a crash for me.
          Did you still have AddIgnoredActor() when you tried the contructor option?

          Comment


            #6
            what crash are you getting?

            you should post your log, around where the crash occurs.

            if you are in your character class and you use

            QueryParams.AddIgnoredActor(this);

            you get a crash?


            Does not happen for me, so post your log details please


            PS, for reference, this works for me:

            Code:
            //Query
            FCollisionQueryParams TraceParams(FName(TEXT("VictoryBPTrace::CharacterMeshSocketTrace")), true, this);
            TraceParams.bTraceComplex = true;
            TraceParams.bTraceAsyncScene = false;
            TraceParams.bReturnPhysicalMaterial = false;
            TraceParams.AddIgnoredActor(this);
            Last edited by Rama; 05-13-2014, 06:09 PM.
            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

            ♥ Rama

            Comment


              #7
              I tried with the constructor, removing QueryParams.AddIgnoredActor(this) and vice-versa.

              The log doesn't seem to be providing much info, and the crash reporter itself crashes. ("The procedure entry point SetCheckUserInterruptShared could not be located in the dynamic link library. C:\WINDOWS\SYSTEM32\dbgeng.dll")

              [2014.05.13-22.11.17:358][189]LogRenderer:Warning: Reallocating scene render targets to support 1136x904.
              [2014.05.13-22.11.18:782][355]LogCrashTracker:


              [2014.05.13-22.11.18:922][355]LogCrashTracker:


              [2014.05.13-22.11.18:922][355]LogWindows: === Critical error: ===


              [2014.05.13-22.11.18:922][355]LogWindows: Fatal error!


              [2014.05.13-22.11.18:922][355]LogExit: Executing StaticShutdownAfterError
              [2014.05.13-22.11.18:930][355]LogWindows: FPlatformMisc::RequestExit(1)
              [2014.05.13-22.11.18:930][355]Log file closed, 05/13/14 15:11:18

              Comment


                #8
                Alright, this is a silly mistake, but I found the issue.

                Code:
                GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, Hit.Actor->GetName());
                is where it crashes (I added some UE_LOGs to test). I'm going to guess it's a null reference for the Hit.Actor, which would make sense. Does UE4 usually report that type of error, though?

                Comment


                  #9
                  Originally posted by raybarrera View Post
                  Does UE4 usually report that type of error, though?
                  Nope, if your code tries to use a null pointer it will simply close to desktop and you're left in the dark where the problem is.

                  Comment


                    #10
                    Always Check Your Pointers

                    Wiki Link:
                    https://wiki.unrealengine.com/Entry_..._Your_Pointers
                    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                    ♥ Rama

                    Comment

                    Working...
                    X