Creating classes "bug"

I have had this happen to me as well when trying to create a class called “Power”. Some times the reason is inexperience and lack of knowledge due to the requirement of needing a module added to your source because your base class is in some library that is no loaded. Other times it is a legit aggregation. To fix my “Power” problem I actually just created the source files by hand, it worked and UE4 compiled and shut up about it.

But this is also a sore spot for me because using namespaces in UE4 is like pulling teeth, I think due to their UBT and macros. I have tried incorporating namespaces in the past but have failed. If we could utilize namespaces every class in UE4 would not need to have a unique name but I am also sure adding that into UBT is not a trivial matter, just saying it would be nice.

I don’t know if this is a BUG, but I’ve fixed some of them and reprted them here but this time I don’t know how to fix it. Many C++ Classes can’t be created because the editor throws an error saying that the class name is being used by another class, I fixed this on the AIController puttin “AIModule” on the Build.cs but now Im trying to create a LevelScriptActor to script my levels but is happening the same, the hot reload fails because there’s another class using that name when clearly there’s not another class in the project using that name.

Got it working again. You have to add the “Levels” on YourProject.Build.cs

This is partly my fault as that error message is sometimes unclear.

I’ve improved it for 4.8 so that in the case where a class is added but fails to compile for some reason, it clearly states that the class has been added but could not be built, and offers you a link to the output log so you can see your build errors.

The warning you see about “class name already in use” is because it really has added the class, it just couldn’t build it; but since it exists, you can’t add another class with that name. I should probably also have it close the class wizard in this case, as it isn’t really a hard-failure like not being able to write the new class file(s) would be.

(Windows only, specifically 8.1) Hopefully this gets seen, but I’ve been following this problem for a while. I still haven’t got it to work on my personal machine on 4.8 preview 2. I’m curious where Visual Studio and UE4 are installed for you, and if this may be caused by having multiple drives. In my case, I have an SSD as my boot drive and a 7200rpm as my storage. Both Unreal and Visual Studio are installed on the mechanical which is my D: drive, but some of the directories for Visual Studios are forced when installed to your local(C:). I’m curious if any staff can clear up if this may be the culprit.

Hey aglet-

Could you elaborate on what is happening for you? As mentioned when you attempt to create a new class even if the initial hot reload fails the class is still created. If you open Visual Studio from your project (File->Open Visual Studio) you should see the class among the rest of the code for your project.

Windows only.Your project may not be called The_Last_Bat.The storage device and file location may be different.

1: Open in Explorer C : \Users\Documents\Unreal Projects\The_Last_Bat\Source\The_Last_Bat

2: Move to temporary folder any where

3 : Open in Explorer C : \Users\Documents\Unreal Projects\The_Last_Bat

4: Delete The_Last_Bat.v12.suo

5 : Open the project The_Last_Bat

6 : Manually create all your classes in the temporary folder

7 : Replace all class continence in temporary folder to C : \Users\Documents\Unreal Projects\The_Last_Bat\Source\The_Last_Bat

8: Delete classes in temporary folder.

Hey 1999-

Could you elaborate on what exactly is happening? What error are you getting? What are you trying to do? Looking at the steps you posted, you were able to successfully add classes to the project. Any additional details you can provide about your issue will help.

Cheers

According to what I saw in this file, it appears that Unreal Engine is using this file to gather if any classes have been built by the user. By deleting this class file, it will be restored on start up and I still have not found out if you need to restore the classes manually.

If you build a class and this error occurs then try typing the name of your class in the C++ class creation wizard and if the name you want is the name that appears as a class template then you can not have that name. Today I had to uninstall and reinstall UE4 to figure that out. The name for your C++ class, can not be the name of any C++ template.

What file are you referring to exactly? Are the steps you posted meant to reproduce the issue or as a fix for the issue? One of your steps says to create classes inside a temporary folder, however attempting to do so generates an error that the class must exist within the Project/Source/Project folder and prevents the class from being created. Please explain what you’re doing and what the result is

The steps should fix the issue. Not create, move the classes to the temporary folder anywhere, from “C : \Users\Documents\Unreal Projects\The_Last_Bat\Source\The_Last_Bat” and recreate the class name then move back to “C : \Users\Documents\Unreal Projects\The_Last_Bat\Source\The_Last_Bat”. I am deleating all the data that tells the UE4 wizard that their is a class with that name. By doing step 6, “Manually create all your classes in the temporary folder” you will restore back those class names. In step 6 if their is a class that you named “cpp” in your temporary folder, then you would use the UE4 wizard to create the class “cpp”. Unreal Engine should not be open in steps 1 to 4, step 5 is when you open UE4, then your project and step 8 is optional.