Training Stream - Tanks vs. Zombies C++ - Live From Epic HQ

Thanks for this first stream, it was really interesting, and I am looking forward the next parts!

Anyone else getting an error when including “PaperSpriteComponent.h” in the Tank.cpp file? I added “Paper2D” in the Tanks.Build.cs file, enabled the Paper2D Plugin, but when I include “PaperSpriteComponent.h” in the Tank.cpp file, it says it cannot open the source file PSC.h. Did I miss something? <3

Hi, Cicisse. I think I touched on this in the stream, but just in case I missed something, let’s go through some reasons we used actors instead of components.

We did actually discuss using components, but for this situation, we didn’t think it was the easiest or best way. For one thing, Blueprints are spawned as actors with hierarchies of components attached, but not as hierarchies of components with no actor. We also thought that using Blueprints and the Blueprint editor would be convenient. Since we have multiple components in our turret, and some turrets may have more components than others, and there’s the possibility of having an artist design some flashier turrets, having an actor spawned from a Blueprint class is what we felt was the way to go. On top of that, while we could override component classes to have different behaviors, such as aiming or firing differently, some of those behaviors would involve controlling multiple different components, and we felt that it would be easier to make each turret its own actor with full knowledge and control of its own components. Note that it’s still possible to do all of this with components, we just didn’t feel it was the easiest or best way, especially given how useful the Blueprint editor can be, especially for artists, as we move beyond the most basic turret types.

Make perfect sens now. Thanks for the reply.

Hi, I had no such problem, did you check the source code: I think they released it, else mine is available on GitHub GitHub - SRombauts/UE4Tanks: Unreal Engine Tanks Tutorial from Epic Games currently on Twitch

I have a similar Problem as Ninjin. When I add #include “PaperSpriteComponent.h” it says that it could not find that file. Because of that, I do not have autocompletion for the TankSprite later.
Despite those problems in the VS-Editor the Project compiles without errors. What might be the reason? (I did add Paper2D in the Build file)

Thesbu, if you’re not seeing autocomplete information, it may be that not enough time has passed for Visual Studio (or whatever extension you’re using) to parse the files and generate the autocomplete information.

Ninjin, I just tested this in 4.10.2, and here’s what I did to get a working compile:

  • Made a new “basic code” project called “TestPaper2DCompile”.
  • Add a C++ class, based on Pawn, called “Tank”.
  • Add this code to Tank.h at the bottom of the ATank class:


	UPROPERTY()	
	class UPaperSpriteComponent* TestComponent;


  • Change the include files section at the top of Tank.cpp to look like this:


#include "TestPaper2DCompile.h"
#include "PaperSpriteComponent.h"
#include "Tank.h"


  • Add this code to ATank::ATank() in Tank.cpp:


	TestComponent = CreateDefaultSubobject<UPaperSpriteComponent>(TEXT("TestSprite"));
	if (!RootComponent)
	{
		RootComponent = TestComponent;
	}
	else
	{
		TestComponent->AttachTo(RootComponent);
	}


  • Change the public dependency line in Paper2DTestCompile.Build.cs to look like this:


		PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "Paper2D" });


  • Return to the editor and press the Compile button.

Using this method, I get it to compile with no problem. I didn’t have to do anything else in the current session. That said, my Paper2D plugin is enabled, so you might need to check that in your “Edit –> Plugins” menu. I see that you already said it’s enabled, but at this point I might double-check, since something strange may be happening. It’s also a little strange about “PSC.h” - I don’t see a file with that name anywhere on my hard drive. If you meant that as shorthand for “PaperSpriteComponent.h”, maybe check to see if you actually have that file. It should be under <Install directory>\4.10\Engine\Plugins\2D\Paper2D\Source\Paper2D\Classes\PaperSpriteComponent.h. On my machine, the install directory is C:\Program Files (x86)\Epic Games. It could be that the file is legitimately missing for some reason, in which case you can probably just reinstall it, or uninstall/reinstall your engine from the launcher.

Could be they have #include “EngineMinimal.h” instead of #include “Engine.h” in the project header?

Stupid question: Where is the project header?

*Btw, my project also compiles, it’s just about VS that tells me it can’t include the file. Basically I just wanted to know why this thing is popping up. No need to tell me what I need to do, you included the code files, I tripple checked them, copy pasted them and yes, PSC.h is PaperSpriteComponent.h, I felt retarded to write this long word a third time, but you are right, I should always include the whole name, so it doesn’t confuse anyone. But I did your steps in the right order (shouldn’t make a difference though) and the error message in VS still appears. Oh and yes, the file is in the exact location you mentioned. And it makes no sense why the Plugin default settings would change, but I checked them… it’s checked. So… Could it be that the error in VS actually also appeared in your project, but not enough time passed in VS, so we could see it in the stream?

**I’m not mad, I’m just dragged down/ annoyed, here is a <3 to compensate for my strange way of writing
<3 <3 <3 <3 <3 <3 <3 <3

***I’m using 4.10.3 But if this is the problem here, I’ll take a break :3

****I even installed the full package of VS, which was like 50gb, checked everything there.

: No, the problem is, that the include file can not be found. I do get an Error-underline under “#include” at the “#include “PaperSpriteComponent.h”” line. I then get a further error when wanting to use a sprite component pointer (like TankSprite) and then of course no autocompletion. The Error on a SpriteComponent-Pointer-Variable is, that the class-type “pointer to incomplete” is not admissible/acceptable. (Pointer-to-Incomplete is the term from VS, not mine)

ZioYuri78: At least in my case there is a “#include “Engine.h”” line in “Tanks.h” (My Project is called Tanks). I asume that’s what you mean?

It have the same name of your project, mine is TanksVSZombies, look at the picture.

Yep!

Okay, found it. But when would it switch to “EngineMinimal.h”?

No, you don’t have to switch to EngineMinimal.h, only if you have EngineMinimal.h change it to Engine.h, sometime could happen when you make a new project it use Minimal instead of full engine header, sorry but i don’t recall the exact case now, but if you have Engine.h you are ok and the problem is not here.

Oh OK, I thought you said last time that it compiled fine but autocomplete didn’t work. If you try to include a file that doesn’t exist, that should be a compilation failure. Can you copy the exact output log from Visual Studio and paste that into the thread? Have you tried the things I talked to Ninjin about? The steps that I described there got me to a compiling project with Paper2D in a pretty short time.

Ninjin, I see that some of your questions have been answered, so I’ll just see if there’s anything left to clean up.

This sounds like something that should not happen. A include directive with a file that can’t be found will cause a compilation failure. Can you post the output log from Visual Studio? Or go to your output log in the editor, clear it (right click in the window, choose Clear Log), and then compile.

Well, the file in the stream compiled without error, the compile completed and everything and we ran it, so I don’t think that’s the case. But there seems to be some confusion about what exactly is going on with regard to errors and this file. I’m really curious what’s happening on your machine.

Thanks! Don’t get too down. Programming has a lot of “how is it possible that this doesn’t work?” moments for all of us. Hopefully, the enjoyment you get by getting through those moments and making something fun will more than make up for them.

4.10.3 should not be the cause of these issues. I used 4.10.3 last night at my house to do some Paper2D stuff and it was fine. Similarly, your installation of VS is not likely the issue. Those error logs will probably help.

Well, it is a little bit difficult.

  1. Yes it compiles without error, as I wrote
  2. In the Editor there are errors as described (but that does not prevent a successful compilation)
  3. Because of the Errors in the Editor I do not get autocompletion, which is unnice
  4. The Error-Message I described is only visible by hovering over the Error in the Editor and so there are no Error codes or log outputs

Yes, I did read your bigger answer and tried. But there’s no change.

A question: What needs to be normally done to make a c+±Paper2D-Project?

  • Adding Paper2D to the list in the *.build.cs
  • Making sure the Paper2D-PlugIn is aktivated
  • sth. further?

Yes, Thesbu and me have the exact same issue. It’s just getting red underlined in VS, but no compilation errors what so ever.

Ninjin and Thesbu, maybe this will help: Setting Up Visual Studio Development Environment for C++ Projects in Unreal Engine | Unreal Engine 5.1 Documentation

I think one reason I may not have these issues is that I use VAX (Visual Assist X, from Whole Tomato Software) both at work and at home instead of Intellisense. On the stream, we didn’t have VAX installed, and just mentioned to me that she thinks we had the red squiggles. (And also reminded me of that link I just sent! Thanks, Lauren!) In the stream, we didn’t do anything with the components other than just spawn them - all the positioning and setting of values that we did was handled in Blueprints. So the autocomplete issue wouldn’t have come up for us. If this is the case, unfortunately, there’s not much I can do, as the issue would be with Intellisense. But you can at least disable parts of it (as shown in the link) to get the false errors to stop showing up. I hope this helps!

I tried your suggestions now. Yes they help.
The squiggles can be disabled as described, but disabling is the opposite of the suggestion in the linked document, isn’t it?
With the free VAX-Trail installed and enabled I indeed do get completion. As soon as I disable (via the VAX-Menu) it, I lose completion again.

So is VAX strongly advised when using c++ with the UnrealEngine?

Could you please test, whether you get Autocompletion for the “TestComponent”-Variable in your toy-project (from the long answer) with VAX disabled.

Update:
With VAX enabled I still can not go to the declaration of the UPaperSpriteComponent with Ctrl-B. Can you?
Sorry please ignore, Ctrl-B is still IntelliSense Alt-G is Vax

Fantastic! I can sleep well today! <3