Announcement

Collapse
No announcement yet.

Need help with intro to UE4 Programming 3 - Creating the base pickup class.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help with intro to UE4 Programming 3 - Creating the base pickup class.

    I'm following the tutorial series about c++ programming as the title says and I've gotten to video three, followed all her steps, wrote the code exactly as she did and I get this:

    Code:
    1>C:/Users/Luna/Documents/Unreal Projects/TutorialCode_CPP/Source/TutorialCode_CPP/Public/PickUp.h(17): error : In PickUp: Member variable declaration: Missing variable type
    1>Error : Failed to generate code for TutorialCode_CPPEditor - error code: 2
    here is my pickup header and .cpp file.

    pickup.h:
    Code:
    // Fill out your copyright notice in the Description page of Project Settings.
    
    #pragma once
    
    #include "GameFramework/Actor.h"
    #include "PickUp.generated.h"
    
    /**
     * 
     */
    UCLASS()
    class TUTORIALCODE_CPP_API APickUp : public AActor
    {
    	GENERATED_UCLASS_BODY()
    
    	/*True when pick up is touched.*/
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = PickUp);
    	bool bIsActive;
    
    	// set this to a UPROPERTY
    	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = PickUp);
    	TSubobjectPtr<USphereComponent> BaseCollisionComponent;
    
    	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = PickUp);
    	TSubobjectPtr<UStaticMesh> PickupMesh;
    
    	/** Function to call when the pick up is collected.*/
    	UFUNCTION(BlueprintNativeEvent);
    	void onPickedUp();
    
    };
    pickup.cpp:
    Code:
    // Fill out your copyright notice in the Description page of Project Settings.
    
    #include "TutorialCode_CPP.h"
    #include "PickUp.h"
    
    
    APickUp::APickUp(const class FPostConstructInitializeProperties& PCIP)
    	: Super(PCIP)
    {
    	// The pickup is active when created.
    	bIsActive = true;
    
    	BaseCollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("Base Sphere Component"));
    
    	// set Sphere component as the root component,
    	RootComponent = BaseCollisionComponent;
    
    	// create static mesh.
    	PickupMesh = PCIP.CreateDefaultSubobject<UStaticMesh>(this, TEXT("Static Mesh"));
    
    	// turn physics on for the battery
    	PickupMesh->SetSimulatePhysics(true);
    
    	PickupMesh->AttachTo(RootComponent);
    }
    
    void APickUp::onPickedUp_Implementation()
    {
    	// there is no function here, move along.
    }
    not sure what I'm doing wrong......

    #2
    If I remember correctly, there was an error in one of these, or rather a deprecated function that is called. It should be covered in the youtube comments...

    EDIT: I can see from the error message that this is not the case...
    It is complaining about the bool, which is called correctly afaik.

    EDIT again: Doh. Remove the ; at the end of all your macros (the UPROPERTY() ones)
    Last edited by oasf; 11-10-2014, 04:06 PM.

    Comment


      #3
      Hmm, Usually that doesn't do anything (error wise, anyways) But thanks. Can't believe it was THAT simple.

      Comment


        #4
        Quick Question: It's telling me that these functions aren't defined in UStaticMesh

        Code:
        	PickupMesh->SetSimulatePhysics(true);
        
        	PickupMesh->AttachTo(RootComponent);
        I'm using UE4 4.5.1 so I assume they changed a few things? Sorry if this info is else where.

        Comment


          #5
          Try AddToRoot() instead...
          Last edited by oasf; 11-10-2014, 05:54 PM.

          Comment


            #6
            Update: Turns out I was making a static mesh, not a static mesh component....totally different functionality.

            Comment

            Working...
            X