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?
Perhaps set it to orthographic, it seems like that’s what you’re after. To switch back:
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.
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.
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).
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!
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.
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.
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:
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:
It works perfectly!
You were also right with this part as well:
Thank you so much for your effort, this was a great help!!! =)