# How do I make the player's camera switch to another camera temporarily?

**URL:** <https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [December 6, 2023, 11:53am UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143 "2023-12-06T11:53:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![d\_aydream](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@d\_aydream](https://forums.unrealengine.com/u/d_aydream)\
**Post date:** [December 6, 2023, 11:53am UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/1 "2023-12-06T11:53:51Z")

</div>

Hello! I’m trying to implement an NPC dialogue system - so when the player presses E when next to an NPC, they start talking to the NPC. I have the dialogue part working but I’d like to make it so the player’s camera switches to a camera in front of the NPC (so basically the player’s perspective is switched so that they are focused on the NPC).

I have already set up a camera within the NPC blueprint as I’m guessing this is the first step for this sort of mechanic, but other than that I have no clue what to do next. Does anyone have any ideas?

![Screenshot 2023-12-06 114936](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/3/44368a512d5fc072bab93037fcb98de92c3e5172.png)  
(This is the camera angle I am aiming for).

 ![Screenshot 2023-12-06 115240](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/3/4/234bf37aa302de44cf24d5399fcde61253ddf447.jpeg)  
(The player would basically be forced to look at the NPC from around this angle, and would not be able to look at them from any other angle).

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 6, 2023, 12:08pm UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/2 "2023-12-06T12:08:11Z")

</div>

You could try:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/a/4aaca82948bb9b3b553b4a30663af60493c8a9c9.png)

Plug in the reference to the NPC as the `New View Target`. In the NPC, you could position the cam as needed:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/e/3eef4cc568f1cb66c26d35528119199526d82187.jpeg)

Perhaps set it to orthographic, it seems like that’s what you’re after. To switch back:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/7/7b763d8122760bce59a49401664a0ec078f42fcc.png)

You can adjust _Blend Time_ to get an animation and play around with curves, too.

Do note that you still have control over the character since they’re possessed. It may help if you disable movement while the conversation is taking place. Otherwise the player may simply wander off and walk into lava, or worse.

---

<div class="post-metadata">

**Author:** ![d\_aydream](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@d\_aydream](https://forums.unrealengine.com/u/d_aydream)\
**Post date:** [December 6, 2023, 12:50pm UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/3 "2023-12-06T12:50:26Z")

</div>

This was really clear, thank you so much!!

For some reason though - when I speak to the NPC, the camera switches to focus much lower down on the NPC. I have tried raising the camera within the NPC blueprint, but that didn’t change anything. I also changed the blend time to 10 to see exactly what was going on, and the camera slowly descended to this same position again.

 ![Screenshot 2023-12-06 124531](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/1/531164721d7af2c9fb9517094c0432ea9244d559.jpeg)

I was thinking I might have set up the NPC reference variable wrong (I’m still a beginner in Unreal Engine and programming in general, so I thought I might have made a mistake such as this).

![Screenshot 2023-12-06 124726](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/7/3/673ecac5429508e53e2ec3d6b1fad81303eece47.png)

![Screenshot 2023-12-06 124737](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/d/a9db69ac0c9ec1f7777efa4a1c5a805834cea601.png)

Do you have any ideas as to what the problem maybe? No worries if not - this may very well be a problem with other parts of my project!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 6, 2023, 12:54pm UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/4 "2023-12-06T12:54:53Z")

</div>

> [@d\_aydream](#):
>
> For some reason though - when I speak to the NPC, the camera switches to focus much lower down on the NPC.

Could you show the component hierarchy in the NPC?

> [@d\_aydream](#):
>
> I might have set up the NPC reference variable wrong

Could you show how the value of the variable is set?

> so when the player presses E when next to an NPC

And this part of the script?

---

<div class="post-metadata">

**Author:** ![d\_aydream](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@d\_aydream](https://forums.unrealengine.com/u/d_aydream)\
**Post date:** [December 6, 2023, 1:26pm UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/5 "2023-12-06T13:26:39Z")

</div>

> [@Everynone](#):
>
> Could you show the component hierarchy in the NPC?

 ![Screenshot 2023-12-06 130428](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/1/bd1b2cb749eb621cef8b4f031959d84583cfa850.png)

I hope this is what you meant!

> [@Everynone](#):
>
> Could you show how the value of the variable is set?

To make the variable, I just made a new variable and from the dropdown list I selected “NPC Example” as an object reference. Again, I hope this is what you meant.

 ![Screenshot 2023-12-06 132511](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/f/3/2f37c8ea15e9f5fb07f1573f9b088e6cb950ff9a.png)

> [@Everynone](#):
>
> And this part of the script?

I wasn’t sure what screenshot I should post exactly here, so I hope at least one of these images are relevant:

 ![Screenshot 2023-12-06 131631](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/c/7/4c748c5e39e2f47a86a6deb35bec0adabbbca5e7.png)  
This is in the First Person Character blueprint, showing what happens when you press E

 ![Screenshot 2023-12-06 132822](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/5/af5ee706f668813347263c18ed30735fce3f1135.png)  
This is the start of the main dialogue code

 ![Screenshot 2023-12-06 132207](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/c/9ec5b9352dac6bb29c1bf3f09a8921b9fcd4c803.png)  
This is the end of the main dialogue code.

The dialogue code is quite long and the middle section of it only really involves asking the player questions with the NPC’s response changing depending on their answers. The only camera related code is at the beginning and end.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 6, 2023, 1:30pm UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/6 "2023-12-06T13:30:03Z")

</div>

- the components are fine
- the variable will not work, it’s null - we do not know which NPC it needs to point at but it might be redundant here, see below:

Isn’t this the NPC we’re going to talk to?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/1/9/51977896759932fd44561657b70deb9139f89c83.png)

If so, I’d plug that into the `Set View Target` node. Or you could even handle the camera switch inside the NPC. I assume that when you send this message, in the NPC you get:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/c/10c0e8f3f9e22df697cce3b909e3bf1ae92df8db.png)

So the NPC could switch to _its own_ point of view.

* * *

Or this is not how any of this works? When you said:

> so when the player presses E when **next to** an NPC

I assumed the _next to_ refers to:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/2/d121ad268f73f864768b880099ca08b7c7a22795.png)

Is this how you find which NPC to talk to? Am I getting close?

---

<div class="post-metadata">

**Author:** ![d\_aydream](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@d\_aydream](https://forums.unrealengine.com/u/d_aydream)\
**Post date:** [December 6, 2023, 3:08pm UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/7 "2023-12-06T15:08:51Z")

</div>

Hi there! Sorry for the late reply - your suggestion works really well!! I put the Set View Target with Blend node directly inside the NPC blueprint like you have shown here:

> [@Everynone](#):
>
> If so, I’d plug that into the `Set View Target` node. Or you could even handle the camera switch inside the NPC. I assume that when you send this message, in the NPC you get:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/c/10c0e8f3f9e22df697cce3b909e3bf1ae92df8db.png)

It works perfectly!

You were also right with this part as well:

> [@Everynone](#):
>
> I assumed the _next to_ refers to:
> 
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/2/d121ad268f73f864768b880099ca08b7c7a22795.png)

Thank you so much for your effort, this was a great help!!! =)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [January 5, 2024, 3:09pm UTC](https://forums.unrealengine.com/t/how-do-i-make-the-players-camera-switch-to-another-camera-temporarily/1495143/8 "2024-01-05T15:09:11Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
