Hi there, I have been experiencing crashes while making my demo on UE4. The crash report said there was something wrong with the “Release Function” I have for my component:
void UGrabber::Grab()
{
UE_LOG(LogTemp, Warning, TEXT("Grabbed"));
FHitResult HitResult = GetFirstPhysicsBodyInReach();
UPrimitiveComponent* ComponentGrab = HitResult.GetComponent();
if (HitResult.GetActor())
{
PhysicsHandle->GrabComponentAtLocation(ComponentGrab, NAME_None, GetPlayerReach());
}
Grabbed = true;
}
void UGrabber::Release()
{
UE_LOG(LogTemp, Warning, TEXT("Released"));
int pulse = 1400;
FHitResult HitResult = GetFirstPhysicsBodyInReach();
UPrimitiveComponent* ComponentGrab = HitResult.GetComponent();
if (Grabbed)
{
PhysicsHandle->ReleaseComponent();
ComponentGrab->AddImpulse(
GetWorld()->GetFirstPlayerController()->AActor::GetActorForwardVector() * pulse,
NAME_None,
true
);
}
Grabbed = false;
And the error messsages:
LoginId:c1c6744445b8f3eac10f52a24f7db053
EpicAccountId:faa1a0f7440240ec8bc49902f8c952de
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000
UE4Editor_Demo_9030!UGrabber::Release() [E:\Uprojectfold\Demo\Source\Demo\Grabber.cpp:135]
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll
The crashes started after I implemented the AddImpulse function.
Also my pawn gets really bouncy and moves uncontrollably if it runs into objects, what can I do to fix that?
Thx!