Make Shooter Game third person (C++)

Hey all,

So I found and followed the tutorial by Chad Reddick on creating a “True First Person” camera via C++ by using the Third Person C++ template. I’d like to be able to do the same for the Shooter template that is available on the Market Place but I’m a total noob when it comes to C++. Anyone know how to do this and feel like explaining it to us programming noobs?

that project is pretty big and a bit complex to explain in 1 shot, plus don’t know where to start also, so i think you have to try first then ask what you want to do specifically, problem by problem. This way someone can easily give you some support rather than this general and wide range question like this.

Hello!
You should start thinking of what are the mechanics you want first. Here is some “template” To do: list for you:

  1. movement
  2. networking the movement
  3. basic menu
  4. basic shooting&damge
  5. basic respawning
  6. basic team&scoreboard system
  7. swappable weapons system
  8. additional mechanics, that you think would be really cool and unique (jetpack? time warp? you have the power to decide :3)
  9. start polishing up the “basic” mechanics
  10. at this point you have probably decided to go a bit different route that fits your particular project better, which is more than okay, as you now should somewhat know what you’re doing.

For actually completing those steps you should watch tutorials, documentation, and ask more questions on answerhub&forums. But try not to simply ask “how do I do this step”; but rather try to figure it out yourself, and ask for details (ie. how do I set playerstate to occupy another pawn?"

Hope this helps to learning the engine, as this is the way I approached it.

-DoctorPC

I was just hoping that there was a way to simply set up a switch so that the game was always using the third person mesh not the first person (floating arms) and then zoom the camera back into the head.

As I said I got all this working based off the Third Person C++ template but the Shooter Game template has sooo much more content that it would be a much more ideal platform to start from.

In shooter character you need to change the Mesh1P to bOnlyOwnerSee = false and bOwnerNoSee = true, reversed that for Mesh3P, so now your 3P mesh will always show, but still there’s a lot of stuff like gun it shoot on 1P Mesh hand, 3P Mesh just represent in other client.

1 thing u could try is remove 1P Mesh and anything related to it and try to replace 3P Mesh in where is necessary.

So I tried what you suggested… Mesh1p->bOnlyOwnerSeee = false bOwnerNoSee = true
as well as changed
Mesh->bOnlyOwnerSeee = true
bOwnerNoSee =false

That didn’t make a difference after a re-compile. The 1st person mesh is still all I see in the viewport.

These changes were made to Source\ShooterGame\Private\Player\ShooterCharacter.cpp

Oh, you need to set the same in PlayerPawn Blueprint also, this only affect if you make a new Pawn, and you should check all Mesh1P and Mesh in ShooterCharacter.cpp if they have been reset somewhere.

Yeah I’ve added a camera and boom to the player pawn blueprint but I don’t see anywhere to specify the true or false for 1p and 3P models. They’re both set to visible in the default settings under the Render Heading but when I spawn only 1P is visible.

do you check bOnlyOwnerSeee and bOwnerNoSee on both mesh ?

So I found a line down at 1125 - 1128 that says:

USkeletalMeshComponent* AShooterCharacter::GetSpecifcPawnMesh( bool WantFirstPerson ) const
{
	return WantFirstPerson == true  ? Mesh1P : Mesh;
} 

I changed this to “false” and now the 3rd Person weapon is floating in the center of the screen along with the First Person arms. The weapon stays centered and the arms move with the Camera but the 3rd Person Character and the First Person weapon are missing.

I’m so very confused.

Hello !

I’ve just finished writing a complete tutorial on how to “properly” (or what I thik is the proper way) adding third person support to the Shooter Game sample. It allows you to toggle between first/third person and doesn’t take away the advantage of using the first person mesh (arms only) in first person view.

Here’s the wiki link: [Shooter Game - Toggle Third Person][1]

Feel free to let me know if I did anything wrong or if some improvements could be added :).

[URL to picture page][3]

Awesome Greg. I’ll be sure to go over it on my next day off and let you know how everything goes!

Looks like its a good tutorial but you don’t tell us directory structure (where to find the .h or .cpp files) or Line Numbers for the code you’re referencing. Might be helpful to add this in.

Well the files are organized in a quite logical and not too big structure so it’s not really hard to find them. As for the line numbers they change all the time as you add more lines and depending on how you do it so.

But I will add for quick reference the part of the original structure I’m using with a little diagram or something.

Oh and thanks for your feedback :slight_smile:

No problem. I’m just trying to point out how it looks to a total noob. I was having a hard time finding the .h file even though I’ve found it before. And I realize that the line numbers change, but you can reference where they are originally and then you can suggest a number for where you should insert the new code and then continue referencing based on that. Approximately line 722 for example will at least point us in the right general area rather than not having a clue if we’re in the correct spot or not.

The tutorial “Shooter Game - Toggle Third Person” not work on UE 4.9

Hi !

Thanks for the feedback. I’ll have a look at it and update it when I get the time. Haven’t had a look at 4.9 yet actually ;).

Hello Greg, thank you so much for your fast response. But the mistake is mine - your code and tutorial works perfect on UE 4.9. I just made it to work without errors on 100%. I published all the six files with changes to save time for your readers. You can attached them in the tutorial.
There is a small problem with the position of the camera when Targeting when click RightMouseButton. If you can please submit a solution.
Best Regards and thank you for your great job.

1stgun normal position

1stgun targeting position

2ndgun normal position

2ndgun targeting position

Hey, is there a way to make it only third person??? I am so desperate!

The easiest way to do this is through the pawn blueprint. Open that into full editing mode then just add a camera to the scene, place it where you want (behind the player) and it will override the original camera. Literally within minutes you can have a nice Gears of War style third person camera.