Hello,
I am trying to follow the battery tutorial, but I cannot succesfully compile the code (from the PickUp tutorial). I know some things changed since 4.6 (as outlined in here) and I tried adapting my code to it, to no avail. i am also getting some weird Visual Studio 2013 errors, which I would appreciate any help on (it is preventing me from compiling this specific project).
My header code looks likes so (I included the newer constructor declaration):
#include "GameFramework/Actor.h"
#include "PickUp.generated.h"
UCLASS()
class TUTORIALCODE_API APickUp : public AActor
{
GENERATED_BODY()
// Constructor declaration
APickUp(const FObjectInitializer& ObjectInitializer);
/** True when the pickup is able to be picked up, false if something deactivates the pickup */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Pickup)
bool bIsActive;
/** Simple colision primitive to use as the root component */
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Pickup)
TSubobjectPtr<USphereComponent> BaseCollisionComponent;
/** StaticMeshComponent to represent the pickup in the level */
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Pickup)
TSubobjectPtr<UStaticMeshComponent> PickupMesh;
/** Function to call when the pickup is collected */
UFUNCTION(BlueprintNativeEvent)
void onPickedUp();
public:
// Sets default values for this actor's properties
APickUp();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
};
My .cpp code looks like so (I included the new constructor which includes FObjectInitializer& ObjectInitializer):
// Fill out your copyright notice in the Description page of Project Settings.
#include "TutorialCode.h"
#include "PickUp.h"
// Sets default values
APickUp::APickUp(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//The pickup is valid when it is created
bIsActive = true;
//Create the root SphereComponent to handle the pickup's collision
BaseCollisionComponent = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("BaseSphereComponent"));
// Set the Spherecomponent as the root component
RootComponent = BaseCollisionComponent;
//Create the static mesh component
PickupMesh = ObjectInitializer.CreateDefaultSubobject<StaticMeshComponent>(this, TEXT("PickupMesh"));
//Turn physics for the static mesh
PickupMesh->SetSimulatePhysics(true);
// Attach the StaticMeshComponent to the root component
PickuMesh->Attachto(RootComponent);
}
void APickup::OnPickedUp_Implementation()
{
//There is no default behavior for a Pickup when it is picked up
}
// Called when the game starts or when spawned
void APickUp::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APickUp::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
My Debug Error List:
Error 1 error code: OtherCompilationError (5) C:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Intermediate\ProjectFiles\Error TutorialCode
Error 2 error MSB3073: The command ""C:\Program Files\Epic Games\4.9\Engine\Build\BatchFiles\Build.bat" TutorialCodeEditor Win64 DebugGame "C:\Users\Nubra\Documents\Unreal Projects\TutorialCode\TutorialCode.uproject" -rocket -waitmutex" exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 TutorialCode
3 IntelliSense: identifier "BaseCollisionComponent" is undefined c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.cpp 19 2 TutorialCode
4 IntelliSense: identifier "PickupMesh" is undefined c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.cpp 25 2 TutorialCode
5 IntelliSense: no instance of overloaded function "FObjectInitializer::CreateDefaultSubobject" matches the argument list
argument types are: (APickUp *, const wchar_t [11])
object type is: const FObjectInitializer c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.cpp 25 32 TutorialCode
6 IntelliSense: identifier "StaticMeshComponent" is undefined c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.cpp 25 56 TutorialCode
7 IntelliSense: identifier "PickuMesh" is undefined c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.cpp 31 2 TutorialCode
8 IntelliSense: name followed by '::' must be a class or namespace name c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.cpp 34 6 TutorialCode
9 IntelliSense: expected a type specifier c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.h 22 2 TutorialCode
10 IntelliSense: expected a type specifier c:\Users\Nubra\Documents\Unreal Projects\TutorialCode\Source\TutorialCode\PickUp.h 26 2 TutorialCode
Error 1 and Error 2 have me stumped. I read somewhere that I need to provide admin privileges to Visual Studio, but I can’t give them to deven.exe. This didn’t happen when I followed the Quick Start Tutorial, either. The rest of the errors (3 through 10) were produced after I tried to adapt the pre 4.6 tutorial code to a more 4.9 version (Which I failed at).
Any help is greatly appreciated. I really want to take the steps to learn from these tutorials