Hello and thanks in advance for helping out.
I’m trying to run through the videos while coding and compiling on a Mac (OS 10.10.1) using UE4 (4.6.0-xxx). The problem I’m seeing is when I have Unreal Editor “Add Class to Project” for the actor “Pickup” as explained in tutorial video #3 “Creating the Base Pickup Class”.
The code generated in the example .cpp file in the video shows:
#include "TutorialCode.h"
#include "Pickup.h"
APickup::APickup(const class FPostConstructInitializeProperties& PCIP) :
Super(PCIP)
{
}
But in XCode, I’m given only the compiler directives:
#include "TutorialCode.h"
#include "Pickup.h"
Question #1: Why doesn’t the UE Editor generate the same code for Mac/XCode projects?
So, since I need to add code to this .cpp file as directed by the video, I added the class definition and corresponding code as follows:
#include "TutorialCode.h"
#include "Pickup.h"
APickup::APickup(const class FPostConstructInitializeProperties& PCIP) :
Super(PCIP)
{
// The pickup is valid when created
bIsActive = true;
// Create the root SphereComponent to handle the pickup's collision
BaseCollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("BaseSphereComponent"));
// Set the SphereComponent as the root component
RootComponent = BaseCollisionComponent;
// Create the static mesh component
PickupMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PickupMesh"));
// Turn physics on for the static mesh
PickupMesh->SetSimulatePhysics(true);
// Attach the StaticMeshComponent to the root component
PickupMesh->AttachTo(RootComponent);
}
void APickup::OnPickedUp_Implementation()
{
// There is no default behavior for a pickup actor when it's picked up
}
When compiled, I get an error at the class definition line APickup::APickup(…) that indicates APickup is being redefined.
Question 2: How do I add the required code without redefining the APickup class and follow the rest of the tutorials on a Mac?
Thank you kindly for helping me out!