x

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"

Problems with custom classes from tutorial video

Alright so to get acquainted with the workings of UE4 coding, I watched some tutorial videos from Epic. First, I followed this video to build the source. Then, I began to follow the steps of this video to add some code to a project. So, in line with the steps there, after building / running the solution, I created a new project ("Pizza"). Then I added the same code that he added:

Powerup.h -

 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "Powerup.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class APowerup : public AActor
 {
     GENERATED_UCLASS_BODY()
 
     UPROPERTY(VisibleDefaultsOnly, Category = Powerup)
     TSubobjectPtr<USphereComponent> TouchSphere;
     
     UPROPERTY(EditDefaultsOnly, Category = Powerup)
     float RotationRate;
 
     virtual void Tick(float DeltaTime) OVERRIDE;
 };
 

Powerup.cpp -

 #include "Pizzav2.h"
 #include "Powerup.h"
 
 
 APowerup::APowerup(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)
 {
     PrimaryActorTick.bCanEverTick = true;
 
     TouchSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("TouchSphereComponent"));
     TouchSphere->SetSphereRadius(20.f, false);
     RootComponent = TouchSphere;
 
     RotationRate = 180.f;
 }
 
 void APowerup::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
 
     fRotator MyRot = GetActorRotation();
     MyRot.Roll += RotationRate * DeltaTime;
     SetActorRotation(MyRot);
 }

Then, I ran the new code, using the "debug editor" mode. It then opens the screen where I can choose a project; I choose "Pizza". But in "Pizza", when I go to add a new blueprint and try to select "Powerup" as my parent class, it doesn't show up! Here's an image to show you what I mean.

Any idea what's going wrong? I hope I didn't miss something stupidly obvious... I'd be happy to provide any additional information about what I did, if that helps.

Product Version: Not Selected
Tags:
more ▼

asked Jul 05 '14 at 08:42 PM in C++ Programming

avatar image

Ramesside
43 2 5 10

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

1 answer: sort voted first
 UCLASS(Blueprintable, BlueprintType) 
 class AAI_Monster : public AAI_Character

UClass has to be blueprintable.

more ▼

answered Jul 05 '14 at 10:56 PM

avatar image

Shoiko
638 57 55 68

avatar image Ramesside Jul 05 '14 at 11:18 PM

I added that and it did not solve the problem.

 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "Powerup.generated.h"
 
 /**
  * 
  */
 UCLASS(Blueprintable, BlueprintType)
 class APowerup : public AActor
 {
     GENERATED_UCLASS_BODY()
 
     UPROPERTY(VisibleDefaultsOnly, Category = Powerup)
     TSubobojectPtr<USphereComponent> TouchSphere;
     
     UPROPERTY(EditDefaultsOnly, Category = Powerup)
     float RotationRate;
 
     virtual void Tick(float DeltaTime) OVERRIDE;
 };
 
avatar image Shoiko Jul 05 '14 at 11:50 PM

Were there any kind of errors in the compiler at all?

What happens if you try to do Add Code to project and check the show all classes to see if your powerup is in that list? I can not get into the editor currently as I'm adding new classes my self.

avatar image Ramesside Jul 06 '14 at 12:16 AM

When I try to add code, I don't see powerup on the list :/

avatar image Ramesside Jul 06 '14 at 12:50 AM

Regarding errors - I don't see anything in particular, besides "Cannot find or open PDB file" (which, I'm quite sure, is not important). Here's a pastebin to my entire build output, though, just in case.

avatar image Shadowriver Jul 06 '14 at 01:12 AM

First of all, child class of AActor does not need Blueprintable as it's inherent that specifier from AActor, so thats definitely was not a problem

Code looks ok to me, so best guess (Shoiko guessing that too) is that compiler misses your class for some reason. Rebuild your project (so everything is compiled from zero) and paste compiler output.

avatar image Ramesside Jul 06 '14 at 06:37 PM

Alright, I rebuilt the whole solution, here's the output:

http://pastebin.com/EthiwcfC

avatar image Shoiko Jul 06 '14 at 06:54 PM

Pathing issue? Maybe?

I have a question did you open the project solution only? It look like you are building the unreal engine as well.

Can you open only the solution for your project? This can befound in:

Documents\Unreal Projects\Pizzav2\Pizzav2.sln

I think you are missing the errors because you are building the engine as well. Opening the solution file will show only issues for your project.

-------- End Detailed Actions Stats ----------------------------------------------------------- 24>ERROR : UBT error : Failed to produce item: A:\Documents\Unreal Projects\Pizzav2\Binaries\Win64\UE4Editor-Pizzav2-Win64-Debug.dll 24> Cumulative action seconds (8 processors): 0.00 building projects, 3941.74 compiling, 0.00 creating app bundles, 0.00 generating debug info, 581.18 linking, 0.00 other 24> UBT execution time: 1232.40 seconds 24>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(43,5): error MSB3073: The command "A:\Documents\GitHub\UnrealEngine\Engine\Build\BatchFiles\Rebuild.bat Pizzav2Editor Win64 Debug "A:\Documents\Unreal Projects\Pizzav2\Pizzav2.uproject"" exited with code 2.

avatar image Ramesside Jul 06 '14 at 07:34 PM

Ah, you must be right. I was rebuilding the whole thing (Solution 'Pizzav2'), which included the engine as well. However, I did open the Pizzav2.sln file, as you can see from the screenshot. Here's the output to rebuilding just the actual game project (the one inside the "Games" folder):

http://pastebin.com/7bWdZ88a

avatar image Shoiko Jul 06 '14 at 07:40 PM

First Error:

fRotator to -> FRotator

That might fix the rest case sensitive types. Also with just the solution open if you open the Pizzav2Character.cpp it should now show red marks for these errors.

:)

2> Pizzav2Character.cpp 2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(21): error C2065: 'fRotator' : undeclared identifier 2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(21): error C2146: syntax error : missing ';' before identifier 'MyRot' 2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(21): error C2065: 'MyRot' : undeclared identifier 2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(22): error C2065: 'MyRot' : undeclared identifier 2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(22): error C2228: left of '.Roll' must have class/struct/union 2> type is 'unknown-type' 2>A:\Documents\Unreal Projects\Pizzav2\Source\Pizzav2\Powerup.cpp(23): error C2065: 'MyRot' : undeclared identifier

avatar image Shoiko Jul 06 '14 at 07:41 PM

also note that if the but errors out it will still let you run the last properly built exe which is why you was able to run but saw none of your changes.

avatar image Ramesside Jul 06 '14 at 09:15 PM

Great, thanks, the problem is now fixed. Strange that I didn't see (or notice?) the red line beforehand.

(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