# Access violation - code c0000005 (first/second chance not available) when calling takedamage

**URL:** <https://forums.unrealengine.com/t/access-violation-code-c0000005-first-second-chance-not-available-when-calling-takedamage/319968>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [May 28, 2015, 1:57am UTC](https://forums.unrealengine.com/t/access-violation-code-c0000005-first-second-chance-not-available-when-calling-takedamage/319968 "2015-05-28T01:57:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexarg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexarg](https://forums.unrealengine.com/u/Alexarg)\
**Post date:** [May 28, 2015, 1:57am UTC](https://forums.unrealengine.com/t/access-violation-code-c0000005-first-second-chance-not-available-when-calling-takedamage/319968/1 "2015-05-28T01:57:14Z")

</div>

Hi all,  
im getting this crash :

```
Access violation - code c0000005 (first/second chance not available)

UE4Editor_CoreUObject!UClass::GetDefaultObject() + 6 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\public\uobject\class.h:1958]
UE4Editor_Engine!ACharacter::ApplyDamageMomentum() + 97 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\character.cpp:345]
UE4Editor_Survival_5609!ABaseCharacter::TakeDamage() + 368 bytes [c:\users\alex\documents\github\survivalkind\source\survival\private\basecharacter.cpp:70]

```

I’m trying to hit a skeletal mesh with a LineTraceSingle and deal damage, so i call:

```
const float ActualDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);

```

on ABaseCharacter wich is subclass of character:

( class SURVIVAL\_API ABaseCharacter : public ACharacter )

I’m calling the TakeDamage on ABaseCharacter from my WeaponInstant class  
(I added some NULL validation just in case)

```
void AWeaponInstant::DealDamage(const FHitResult& Impact, const FVector& ShootDir)
{
	GEngine->AddOnScreenDebugMessage(-1, 1.0, FColor::Yellow, "DEAL DAMAGE ");
	FPointDamageEvent PointDmg;
	PointDmg.DamageTypeClass = DamageType;
	PointDmg.HitInfo = Impact;
	PointDmg.ShotDirection = ShootDir;
	PointDmg.Damage = HitDamage;
	if (Impact.GetActor() != NULL && Impact.GetActor()->IsValidLowLevel()){
		if (MyPawn->Controller->IsValidLowLevel()){
			Impact.GetActor()->TakeDamage(PointDmg.Damage, PointDmg, MyPawn->Controller, this);
		}
	}
}

```

I tried also a linetrace impacting a PlayerCharacter who is also subclass of ABaseCharecter ( instantiated directly on the map ) , and it works perfectly .  
The problem is with some another character that also inherits from BaseCharacter like “ZombieCharacter”, (using the same method TakeDamage ) and who is controlled by a AIController

Sorry for my English. I just spend a couple of hours with this and i dont understand why i’m getting this error
