Access Violation & bWantsBeginPlay Errors

  1. Access violation - code c0000005 (first/second chance not available)
  2. bWantsBeginPlay was inconsistently enforced

Two errors I’m getting from the Grabber component. At first, while writing the code myself I was getting the second compiling error. I didn’t touch anything in the constructor, so I had no idea what happened. Then, I put in the lecture’s provided code and still got the same error. Also, both times I changed the GrabComponent to GrabComponentActLocationWithRotation. Eventually it would compile, but then it just wouldn’t run, and instead would crash the editor. So with my own code and the provided code, I’m really stuck. I think I’ve come to the conclusion that grabbedcomponent() check is the issue:

if (PhysicsHandle->GrabbedComponent) {
PhysicsHandle->SetTargetLocation(LineTraceEnd);
}

I’m using version 4.14.1

Since you put solved but didn’t give a solution…

BuildingEscape was made with an earlier version of Unreal, bWantsBeginPlay is now deprecated as of version 4.14, currently it should only be a warning and you should still be able to compile with that code in your constructor.

GrabComponent is also deprecated, replaced with GrabComponentAtLocation and GrabComponentAtLocationWithRotation. Again this is only deprecated so it should be a warning not an error so will still compile (though might not in a future version when it’s actually removed).

The crash is most likely because PhysicsHandle is nullptr so calling PhysicsHandle->GrabbedComponent will cause a crash. Solution would to be to add an additional check

if(PhysicsHandle && PhysicsHandle->GrabbedComponent)

That works because if PhysicsHandle is nullptr it wouldn’t continue with the second half of that conditional.

2 Likes

Privacy & Terms