Why can't I compile code in the editor when it will compile in VS?

You are only able to change specific values and re-compile in the code I believe. Certain things like swapping function arguments and certain variables will mean that you have to close the editor and compile in VS, before re-opening the editor.

I try to compile code like in this video: Introduction to Programming | Live Training | Unreal Engine - YouTube
When I compile code in Visual Studio 2013 Professional it works. But when I click “Recompile Game Code” in the editor I get these errors:

I didn’t add new headers, classes, etc. I’m doing like in the video. I’m just changing “.Roll” to “.Yaw”.
How can I fix it? It will be too slow if I close the editor every time when I want to apply minor changes

In the video he’s doing the same. Look at 19:40

Hi ,

I went through the tutorial in an effort to reproduce the issue that you described, but it worked fine for me. What version of the Editor are you using, and are you using one compiled from Source, or from the Launcher? Would you mind posting the code you have in the Powerup.h and Powerup.cpp files that you created in the tutorials?

Thanks.

I’m using the editor compiled from Source. Version 4.1.0. I named my project ‘PromoWinter’ and new class isn’t ‘Powerup.h’, but it’s ‘Pizza.h’. But my code is the same as in the video. Almost)

class APizza : public AActor
{
	GENERATED_UCLASS_BODY()
	UPROPERTY(VisibleAnywhere, Category=Powerup)
	TSubobjectPtr<USphereComponent> TouchSphere;	
	UPROPERTY(VisibleAnywhere, Category=Powerup)
	float RotationRate;
	virtual void Tick(float DeltaTime) OVERRIDE;
};

and

APizza::APizza(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	PrimaryActorTick.bCanEverTick = true;
	TouchSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("TouchSphereComponent"));
	TouchSphere->SetSphereRadius(20.f, false);
	RootComponent = TouchSphere;

	RotationRate = 175.f;	
}

void APizza::Tick(float DeltaTime) {
	Super::Tick(DeltaTime);
	FRotator MyRot = GetActorRotation();
	MyRot.Roll += RotationRate * DeltaTime;
	SetActorRotation(MyRot);
}

But I think that the problem doesn’t stems from the code, because Visual Studio compile it fine.

Hi ,

I tried going through the tutorial again using your exact code and project/class names and was again unable to recreate the issue you described. I was using 4.1.1, so I need to try to revert back to 4.1.0 and try again.

There is always a possibility that code that builds successfully in VS will not work in UE4. VS checks for syntax errors and not much else (VS assumes that you know what you are doing). The UBT and UHT do some additional checks, but your code does not actually get fully checked until you run it in the Editor. One example I ran into recently was calling a function in GEngine without first checking to make sure the reference to GEngine was valid. It built fine in VS, but it was impossible to open the project in the Editor until that check was put into the code.

I will try to revert back to 4.1.0 on Monday and make another attempt at reproducing this issue.

Oh, I’m sorry for the troubles

Hi ,

It isn’t a problem at all. I just reverted back to 4.1.0 and tried again with the code samples you provided and everything seemed to work fine.

A few more questions: It shouldn’t make a difference, but just so I can test it and make sure, what Solution Configuration did you have set in VS when you built the project? Was it set to Debug Editor?

I realize it is a bit of a hassle, but would you mind trying to go through the tutorial again with a new project to see if the same issue appears there?

I looks like the UE4 editor holds onto some files. I would recommend using the recompile c++ code button in the UE4 editor to recompile your c++ code if you have the UE4 editor open. That being said there are still only so many things that you can change and have the hot reload feature work right. For example, it doesn’t seem that you can change header files too much but you can change most of the functionality in a function. I have also noticed that you can’t really change the constructors and have things work right.

Hi ,

We have not heard back from you for a while, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with any additional information you may have and we will offer further assistance.

Thank you.