# How to add Damage to Actor got from Hitresult

**URL:** <https://forums.unrealengine.com/t/how-to-add-damage-to-actor-got-from-hitresult/373919>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [October 20, 2016, 2:17pm UTC](https://forums.unrealengine.com/t/how-to-add-damage-to-actor-got-from-hitresult/373919 "2016-10-20T14:17:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon49701631](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon49701631](https://forums.unrealengine.com/u/anon49701631)\
**Post date:** [October 20, 2016, 2:17pm UTC](https://forums.unrealengine.com/t/how-to-add-damage-to-actor-got-from-hitresult/373919/1 "2016-10-20T14:17:50Z")

</div>

Hey Guys,

I am stuck here at a simple scenario:

- Shooting a Raycast with the Mouse Cursor through the screen
- FHitResult returns the Actor of the HitResult.
- TakeDamage() shall add Damage to the Actor in the Scene.

So is this possible or is the FHitResult just a copy of the actual object and modifying it doesn’t affect the actual Actor in the game?

I hope my question is clear. Thank you alot in advance 🙂

```
void URaycastComponent::ShootRaycast()
	{
		/// LINE TRACE and see if we reach any actors with physics body collision channel set
		FHitResult HitResult = GetFirstPhysicsBodyInReach();
				
		auto ActorHit = HitResult.GetActor();
		if (ActorHit)
			{
			FString ObjectName = ActorHit->GetName();
			UE_LOG(LogTemp, Warning, TEXT("Hit Object: %s"), *ObjectName)
			DestroyObject(HitResult); // DOESNT CHANGE THE OBJECT
			}
	}

void URaycastComponent::DestroyObject(FHitResult &HitResult)
	{
	// Create a damage event  
	TSubclassOf<UDamageType> const ValidDamageTypeClass = TSubclassOf<UDamageType>(UDamageType::StaticClass());
	FDamageEvent DamageEvent(ValidDamageTypeClass);

	const float DamageAmount = 10000.0f;
	HitResult.GetActor()->TakeDamage(DamageAmount, DamageEvent, PlayerController,GetOwner());
	HitResult.Actor->TakeDamage(DamageAmount, DamageEvent, PlayerController, GetOwner());
	}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_210522a1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_210522a1](https://forums.unrealengine.com/u/anonymous_user_210522a1)\
**Post date:** [October 20, 2016, 2:42pm UTC](https://forums.unrealengine.com/t/how-to-add-damage-to-actor-got-from-hitresult/373919/2 "2016-10-20T14:42:01Z")

</div>

Try using

```
UGameplayStatics::ApplyPointDamage(HitActor, DamageAmount, LocationDamgeCameFrom, FHitResult, Instigator, DamageCauser, DamageType);

```

I can comfirm that this works, this is what I use in my own project:

```
UGameplayStatics::ApplyPointDamage(HitActor, Damage, GetActorLocation(), Hit, GetInstigatorController(), this, UDamageType_Bullet::StaticClass());

```
