Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Getting errors by creating a actor class from ue4

Created a brand new project and it compiled fine. I added an actor class to my code and I'm getting errors now like "name followed by '::' must be a class or namespace name" Haven't changed the code or or anything, following along with the youtube tutorials. Any help is much appreciated.

I'm using UE 4.12 and VS 2015 Community Edition

alt text

Product Version: UE 4.12
1.png (44.1 kB)
more ▼

asked Sep 18 '16 at 03:22 PM in C++ Programming

avatar image

8 3 4 9

avatar image Shadowriver Sep 18 '16 at 07:20 PM

What did you use to create class? VS?

avatar image BaseDrop0 Sep 18 '16 at 10:14 PM

Though unreal. Under File>New C++ Class>Actor

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

"name followed by '::' must be a class or namespace name" means that, for whatever reason, VS doesn't know about the APickup class you've defined.

Make sure you've got your "{MyGame}.h" include at the top of your .cpp file (where {MyGame} is the name of your game project include [is that what "CodingTest.h" is?]).

Can you post the contents of Pickup.h? There may be a formatting error there.

more ▼

answered Sep 19 '16 at 05:06 AM

avatar image

1.7k 43 13 61

avatar image BaseDrop0 Sep 19 '16 at 10:00 PM

I added the {MyGame}.h but getting "cannot open source file" yes the name of the project is CodingTest

Here is Pickup.halt text

2.png (20.5 kB)
avatar image GigasightMedia Sep 20 '16 at 01:39 AM

If you already had "CodingTest.h" included in your .cpp then that was the "{MyGame}.h" file; I don't mean to literally add "{MyGame}.h", I'm using {MyGame} as a placeholder for whatever your game project is called.

Try deleting the ".vs", "Binaries", and "Intermediate" directories within your project folder (make sure Visual Studio isn't open); and then regenerate the project files (Right-Click on your .uproject file, and select "Generate Visual Studio Project Files". When that's done, open your project in Visual Studio, allow it to scan your project, and then when it's ready try the build again.

It looks like Visual Studio isn't finding the Pickup.h file, if forcing the project re-scan doesn't help, can you post the directory structure that leads to your Pickup.h and Pickup.cpp files?

i.e. "Project Directory/Source/Actors/Pickup.h" "Project Directory/Source/Actors/Private/Pickup.cpp"

As a long shot, you could also try adding a call to the AActor constructor:

     PrimaryActorTick.bCanEverTick = true;

If you get errors from your build, please post the content of the Output tab so we can get a better idea of what's going on.

avatar image BaseDrop0 Sep 20 '16 at 02:22 AM

I did delete the stuff and regenerated the project but still got the errors. I try adding the code and got more errors, idk if I just put it in wrong. Very new to codding in Unreal

avatar image GigasightMedia Sep 20 '16 at 02:43 AM

Please post the contents of the Output tab after running your build, and post the directory structure and filenames for your Pickup.h and Pickup.cpp files.

Also, go ahead an post the contents of Pickup.h and Pickup.cpp so I can be sure where you're at with the code.

It also might be helpful to see a screengrab of your solution explorer in Visual Studio expanded to your Pickup.h and Pickup.cpp files.

avatar image BaseDrop0 Sep 20 '16 at 02:54 AM

Sorry, the photo must have not uploaded. Photo Posted of error list and .cpp and .h

Output: 1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------ 2>------ Build started: Project: CodingTest, Configuration: DebugGame_Editor x64 ------ 2> Performing 2 actions (4 in parallel) 2> Pickup.cpp 2>C:\Users\Name\Documents\Unreal Projects\CodingTest\Source\CodingTest\Private\Pickup.cpp(15): error C2447: '{': missing function header (old-style formal list?) 2>ERROR : UBT error : Failed to produce item: C:\Users\Name\Documents\Unreal Projects\CodingTest\Binaries\Win64\UE4Editor-CodingTest-Win64-DebugGame.pdb 2> Total build time: 0.96 seconds 2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(41,5): error MSB3075: The command ""C:\Program Files (x86)\Epic Games\4.12\Engine\Build\BatchFiles\Build.bat" CodingTestEditor Win64 DebugGame "C:\Users\Name\Documents\Unreal Projects\CodingTest\CodingTest.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command. ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

alt text

alt text

3.png (134.3 kB)
4.png (17.1 kB)
avatar image GigasightMedia Sep 20 '16 at 03:08 AM

You've doubled up the body of your constructor, delete lines 11 - 14 in Pickup.cpp

Try your build again and see what happens.

Also, you're posting the "Errors" list from Visual Studio, that's an unreliable tool with UE4. If you look at the bottom of that window you'll see an "Output" tab, post the messages from that instead.

avatar image BaseDrop0 Sep 20 '16 at 03:25 AM

Deleted 11-14 and rebuild the code and build the code and it works now. It seems I just need to add a line of code. Thank you so much for the help, been waiting a long time work out a bunch of problems between UE4 and VS. Thank you for your time and have a nice day.

avatar image GigasightMedia Sep 20 '16 at 03:34 AM

I betcha the fix was regenerating the project files. That's often a necessary step after adding new files.

Glad it's working for you.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question