# Change camera on death to killer camera \[c++\]

**URL:** <https://forums.unrealengine.com/t/change-camera-on-death-to-killer-camera-c/431522>\
**Category:** Cinematics & Media\
**Tags:** death, unreal-engine, CPP, question\
**Created:** [August 13, 2018, 12:02am UTC](https://forums.unrealengine.com/t/change-camera-on-death-to-killer-camera-c/431522 "2018-08-13T00:02:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_954f1a4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_954f1a4a](https://forums.unrealengine.com/u/anonymous_user_954f1a4a)\
**Post date:** [August 13, 2018, 12:02am UTC](https://forums.unrealengine.com/t/change-camera-on-death-to-killer-camera-c/431522/1 "2018-08-13T00:02:10Z")

</div>

Hello, on death i want to set dead player camera to the killer camera(make him his spectator)  
(You die → you spectate player who killed you)  
So now i do it:

```
APlayerController*PlayerController = UGameplayStatics::GetPlayerController(this, 0);

	PlayerController->SetViewTargetWithBlend(DamageCauser, 2.0f);

```

And its setting Camera of damagecauser to a place in damagecauser’s stomach(?)

I tried reversing to see if it works the opposite way:

APlayerController\*PlayerController = UGameplayStatics::GetPlayerController(DamageCauser, 0);

```
	PlayerController->SetViewTargetWithBlend(this, 2.0f);

```

And now it sets Damagecauser camera to killed player camera. But i dont know why it wont work like i want it to.

Death Code:

```
	APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);

	OurPlayerController->SetViewTargetWithBlend(DamageCauser, 2.0f);

	

	bDied = true;
	UE_LOG(LogTemp, Log, TEXT("die"));
	GetMovementComponent()->StopMovementImmediately();

	GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);

	DetachFromControllerPendingDestroy();

	SetLifeSpan(5.0f);
	CurrentWeapon->SetLifeSpan(5.0f);

```

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [August 13, 2018, 1:57am UTC](https://forums.unrealengine.com/t/change-camera-on-death-to-killer-camera-c/431522/2 "2018-08-13T01:57:59Z")

</div>

Is there a param on the camera manager for view offset or character eye height?  
Do you need to set the target to the Character pawn or to the controller?

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [December 12, 2018, 8:53pm UTC](https://forums.unrealengine.com/t/change-camera-on-death-to-killer-camera-c/431522/3 "2018-12-12T20:53:51Z")

</div>

Sorry I was gone so long. Does it Work to set the view target not to the killer player pawn but to the killer pawn’s camera component?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_954f1a4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_954f1a4a](https://forums.unrealengine.com/u/anonymous_user_954f1a4a)\
**Post date:** [December 16, 2018, 11:20am UTC](https://forums.unrealengine.com/t/change-camera-on-death-to-killer-camera-c/431522/4 "2018-12-16T11:20:37Z")

</div>

Hi mightyenigma! When i was writing this post i didn’t know that i can’t get other player controller from scharacter, but now i know how to do everything 🙂
