Announcement

Collapse
No announcement yet.

Tutorials outdated?

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

  • replied
    Oh thankss, I think I get it now. That fixed 4/4 of my errors.

    Leave a comment:


  • replied
    GENERATED_UCLASS_BODY() is the old macro which is deprecated since version 4.6. When you use it you don't need to declare your constructor in the header file but you always have to override the default constructor. In addition you use FPostConstructInitializeProperties.

    GENERATED_BODY() is the newer version where you explicitly have to declare the constructor in the header file if you want to override it. In addition you use FObjectInitializer.

    A brief explanation on how to use the newer version can be found here: https://forums.unrealengine.com/show...l=1#post181552

    Leave a comment:


  • replied
    Never mind, thanks both of you, it works! I just had to build it a few times before my Visual Studio realised it was fine.

    One thing is, I'm using GENERATED_UCLASS_BODY() in my header file yet Skynet, you used GENERATED_BODY(). What's the difference? I don't want to change my code to use GENERATED_BODY() yet incase it messes up again. :/

    Finally, I can't find any other FPS tutorials for Unreal Engine that are completely up-to-date. Does anyone know of any? I won't ever be using UE4 below version 4.6 so there's not much point of me knowing UE4 4.3 code.
    Last edited by KingFaris10; 01-01-2015, 02:14 PM.

    Leave a comment:


  • replied
    Originally posted by Skynet View Post
    I guess you are using the latest version of the engine, which would make FPostConstructInitializeProperties deprecated.
    It's FObjectInitializer now.

    The following code should be working:
    Code:
    //MyGameMode.h
    UCLASS()
    class THIRDPERSONTUTORIAL_API AMyGameMode : public AGameMode
    {
    public:
    	GENERATED_BODY()
    	AMyGameMode(const class FObjectInitializer& PCIP);	
    	virtual void StartPlay() override;
    };
    Code:
    //MyGameMode.cpp
    AMyGameMode::AMyGameMode(const class FObjectInitializer& PCIP) 
    : Super(PCIP)
    {
    
    }
    
    void AMyGameMode::StartPlay()
    {
    	Super::StartPlay();
    	if (GEngine)
    	{
    		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
    	}
    }
    Thanks for the help, here's my new code:

    FPSGameMode.h
    Code:
    #include "GameFramework/GameMode.h"
    #include "FPSGameMode.generated.h"
    
    UCLASS()
    class FPSPROJECT_API AFPSGameMode : public AGameMode {
    public:
    	GENERATED_UCLASS_BODY()
    	AFPSGameMode(const class FObjectInitializer& PCIP);
    
    	virtual void StartPlay() override;
    };
    FPSGameMode.cpp
    Code:
    #include "FPSProject.h"
    #include "FPSGameMode.h"
    
    AFPSGameMode::AFPSGameMode(const class FObjectInitializer& PCIP) : Super(PCIP) {
    	
    }
    
    void AFPSGameMode::StartPlay() {
    	Super::StartPlay();
    
    	StartMatch();
    
    	if (GEngine)
    	{
    		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
    	}
    }
    Edit: Never mind, no more errors. Fixed as said below.
    Attached Files
    Last edited by KingFaris10; 01-01-2015, 02:29 PM.

    Leave a comment:


  • replied
    Thanks, I tried updating that but then I saw the below code and tried that as it is pretty much what you said.

    Leave a comment:


  • replied
    I guess you are using the latest version of the engine, which would make FPostConstructInitializeProperties deprecated.
    It's FObjectInitializer now.

    The following code should be working:
    Code:
    //MyGameMode.h
    UCLASS()
    class THIRDPERSONTUTORIAL_API AMyGameMode : public AGameMode
    {
    public:
    	GENERATED_BODY()
    	AMyGameMode(const class FObjectInitializer& PCIP);	
    	virtual void StartPlay() override;
    };
    Code:
    //MyGameMode.cpp
    AMyGameMode::AMyGameMode(const class FObjectInitializer& PCIP) 
    : Super(PCIP)
    {
    
    }
    
    void AMyGameMode::StartPlay()
    {
    	Super::StartPlay();
    	if (GEngine)
    	{
    		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
    	}
    }

    Leave a comment:


  • replied
    Since version 4.6 you need to explicitly declare a constructor in your header file if you want to overwrite it. In addition you need to use FObjectInitializer instead of FPostConstructInitializeProperties, both explained in this thread: https://forums.unrealengine.com/show...Mac-with-XCode

    Leave a comment:


  • replied
    Thanks for the quick reply, here's my code for the .cpp:
    Code:
    #include "Engine.h"
    #include "FPSProject.h"
    #include "FPSGameMode.h"
    
    AFPSGameMode::AFPSGameMode(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) {
    	
    }
    
    void AFPSGameMode::BeginPlay() {
    	Super::BeginPlay();
    
    	StartMatch();
    
    	if (GEngine) {
    		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
    	}
    }
    Errors:
    Click image for larger version

Name:	62d38ed9f1b5b64ff5364a9b58391d8b.png
Views:	1
Size:	17.7 KB
ID:	1064745
    Click image for larger version

Name:	14a9317c7d7fdee8ac358c90bbef5a70.png
Views:	1
Size:	16.8 KB
ID:	1064746

    Edit:
    The weird thing is, it is saying the class "UVertexAnimBase" but the Super::BeginPlay() should be referring to FPSGameMode.h's BeginPlay() void. I tried it with StartPlay() and I got an error, I think it's the same error.
    Last edited by KingFaris10; 01-01-2015, 09:12 AM.

    Leave a comment:


  • replied
    Its quite common to see errors with the generated include files if you have other errors, that's because they probably haven't been generated yet (they are generated when you build) because of the other errors prevent it from ever getting to that point. At first glance, your code seems fine, but do you have the associated '.cpp' file also created? If so can you show it?

    Leave a comment:


  • started a topic Tutorials outdated?

    Tutorials outdated?

    Hi, I'm following this tutorial: https://wiki.unrealengine.com/First_...2B%2B_Tutorial

    Though even the first step of the code bit about adding the code to the headers is giving me errors. The autogenerated class has like no constructor for .cpp and the header file has an error for the FPSGameMode.generated.h file in #include.

    Code here:
    Code:
    #pragma once
    
    #include "GameFramework/GameMode.h"
    #include "FPSGameMode.generated.h"
    
    UCLASS()
    class FPSPROJECT_API AFPSGameMode : public AGameMode
    {
    	GENERATED_BODY()
    
    	virtual void StartPlay() override;
    };
    Error here:
    Click image for larger version

Name:	42abf7bc6daf47dcd384ccb3158f0dfd.png
Views:	1
Size:	6.6 KB
ID:	1142462
Working...
X