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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Help with compiler error with "Introduction to UE4 Programming" Tutorial

I'm following the Introduction course for UE4 programming, and have reached part 4, but when I try to compile the code I get a error C3668, havve been looking around, but the one answer I found, did not in any way explain the problem or how to fix it... at least not for me.

My set up is Windows 7 64, UE4.6.1 and I use MVSExp 2013

My code so far is:

This is my BatteryPickup Code, with the error: The *.cpp file The *.h file

This is the previous 2 files from the earlier lesson:

The *.cpp file

Not able to upload the screenshot, so here's the code for the Pickup.h file

 UCLASS()
 class TUTORIALBATTERY_API APickup : public AActor
 {
     GENERATED_BODY()
 
 public:
     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 collision primitive to use as the root component*/
     UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Pickup")
         USphereComponent* BaseCollisionComponent;
 
     /* StaticMeshComponent to represent the pickup in the lvl */
     UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Pickup")
         UStaticMeshComponent* PickupMesh;
 
     /* Function to call when the Pickup is collected */
     UFUNCTION(BlueprintNativeEvent)
         void OnPickedUp_Implementation();
 
 
 };

Hope you can help me to identify the cause of the problem and rectify it.

Product Version: Not Selected
Tags:
error_c3668_2.png (41.5 kB)
error_c3668_1.png (41.4 kB)
error_c3668_3.png (54.5 kB)
more ▼

asked Feb 10 '15 at 12:57 PM in C++ Programming

avatar image

Hardishane
33 5 10 13

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

1 answer: sort voted first

Hi Hardishane,

You have this error cause you cannot override non-virtual function. Also BlueprintNativeEvent means that this function is designed to be overridden by a Blueprint, but also has a native implementation. Provide a body named [FunctionName]_Implementation instead of [FunctionName]; the autogenerated code will include a thunk that calls the implementation method when necessary. You should declare you function like that:

 PickeUp.h
 UFUNCTION(BlueprintNativeEvent, category = adfs)
 void OnPickedUp();  // Cannot be virtual cause BlueprintNativeEvent specifier

 PickeUp.cpp
 void APickeUp::OnPickedUp_Implementation()
 {
     // to do smth here. This function is generated by UHT and it is virtual, you can override it in derived classes.
 }

Best regards, Gleb

more ▼

answered Feb 10 '15 at 03:13 PM

avatar image

Gleb.Bulgakov
1.8k 76 19 143

avatar image Hardishane Feb 10 '15 at 05:08 PM

Hi Gleb

I Take it that its a bit tricky for a new-come programmer to use the _Implementation in header files, and that if not totally sure you should avoid it :)

Thanks for the answer, solved my problem elegantly :)

(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