Announcement

Collapse
No announcement yet.

"Introduction to UE4 Programming" Tut Not Working Wit 4.6 ?

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

    "Introduction to UE4 Programming" Tut Not Working Wit 4.6 ?

    Hello mates.

    I am new to the UE4 programming. Decided to make a start and got on this one.

    https://docs.unrealengine.com/latest...eo=ZPn4N3ckP8I


    Then I remembered with 4.6 some changes were made. Than followed here to make the necessary changes with cınstructor and pointers.

    https://forums.unrealengine.com/show...ansition-Guide


    But I still get tremendous errors ( around 25) fır just a a .cpp and .h file that include around 20 lines of code or something. Serch around quite a bi but decided to ask it on forums to see if I can get some help.


    I just created an Actor from editor just like the tutorial suggested and here is the .cpp and .h files, error log and a screenshot.

    Visual Studio 2013, x64.


    .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_API APickup : public AActor
    {
    	GENERATED_BODY()
    
    	APickup(const FObjectInitializer& ObjectInitializer);
    
    
    	/** True when the pickup is available to be picked, faşse if something deactivates the pickup. */
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Pickup)
    	bool bIsActive;
    	
    
    	/**Simple collision component to use as root component*/
    	UPROPERTY(VisibleDefaultOnly, BlueprintReadOnly, Category = Pickup)
    	USphereComponent* BaseCollisionComponent;
    
    	/**Static mesh to represent the pickup in the level*/
    	UPROPERTY(VisibleDefaultOnly, BlueprintReadOnly, Category = Pickup)
    	UStaticMeshComponent* PickupMesh;
    
    
    	/**Function to call when the pickup is collected*/
    	UFUNCTION(BlueprintNativeEvent)
    	void OnPickedUp();
    };


    .cpp


    Code:
    // Fill out your copyright notice in the Description page of Project Settings.
    
    #include "TutorialCode.h"
    #include "Pickup.h"
    
    
    
    
    APickup::APickup(const FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer)
    {
    
    
    	/**The ickup is active when ceated*/
    	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 static mesh component*/
    	PickupMesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PickupMesh"));
    
    	/**Turn physics on for the statşc mesh*/
    	PickupMesh->SetSimulatePhysics(true);
    
    	/**Attach static mesh to root component*/
    	PickupMesh->AttachTo(RootComponent);
    
    };
    
    void APickup::OnPickedUp()
    {
    	/**There is no default behavior for a pickup when it is pickedup*/
    
    };


    Error Log:



    Code:
    Error	1	error : In Pickup: BlueprintReadWrite should not be used on private members	C:\UE4\Projects\TutorialCode\Source\TutorialCode\Public\Pickup.h	18	1	TutorialCode
    Error	2	error code: OtherCompilationError (2)	C:\UE4\Projects\TutorialCode\Intermediate\ProjectFiles\Error	TutorialCode
    Error	3	error MSB3073: The command ""C:\UE4\Epic Games\4.6\Engine\Build\BatchFiles\Build.bat" TutorialCodeEditor Win64 DebugGame "C:\UE4\Projects\TutorialCode\TutorialCode.uproject" -rocket" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38	5	TutorialCode
    	4	IntelliSense: identifier "FGuid" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Core\Public\Serialization\ArchiveBase.h	561	26	TutorialCode
    	5	IntelliSense: identifier "FGuid" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Core\Public\Serialization\ArchiveBase.h	569	18	TutorialCode
    	6	IntelliSense: identifier "FGuid" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Core\Public\Serialization\ArchiveBase.h	770	24	TutorialCode
    	7	IntelliSense: identifier "FOnSelectedLevelsChangedEvent" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Engine\Classes\Engine\World.h	1976	2	TutorialCode
    	8	IntelliSense: identifier "UParticleModuleEventSendToGame" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Engine\Classes\Particles\ParticleSystemComponent.h	890	68	TutorialCode
    	9	IntelliSense: identifier "UParticleModuleEventSendToGame" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Engine\Classes\Particles\ParticleSystemComponent.h	903	68	TutorialCode
    	10	IntelliSense: identifier "UParticleModuleEventSendToGame" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Engine\Classes\Particles\ParticleSystemComponent.h	921	69	TutorialCode
    	11	IntelliSense: identifier "UParticleModuleEventSendToGame" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Engine\Classes\Particles\ParticleSystemComponent.h	933	42	TutorialCode
    	12	IntelliSense: no instance of constructor "FReadSurfaceDataFlags::FReadSurfaceDataFlags" matches the argument list	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Engine\Public\UnrealClient.h	57	92	TutorialCode
    	13	IntelliSense: no instance of constructor "FReadSurfaceDataFlags::FReadSurfaceDataFlags" matches the argument list	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\Engine\Public\UnrealClient.h	65	87	TutorialCode
    	14	IntelliSense: identifier "FMeshBatchElement" is undefined	c:\UE4\Epic Games\4.6\Engine\Source\Runtime\ShaderCore\Public\VertexFactory.h	488	131	TutorialCode
    	15	IntelliSense: cannot open source file "Pickup.generated.h"	c:\UE4\Projects\TutorialCode\Source\TutorialCode\Public\Pickup.h	6	1	TutorialCode
    	16	IntelliSense: "Super" is not a nonstatic data member or base class of class "APickup"	c:\UE4\Projects\TutorialCode\Source\TutorialCode\Private\Pickup.cpp	10	3	TutorialCode
    	17	IntelliSense: no default constructor exists for class "AActor"	c:\UE4\Projects\TutorialCode\Source\TutorialCode\Private\Pickup.cpp	11	1	TutorialCode


    Here is a screenshot. Please notice the Private and Public parts on the left. I dşdn't create those and in tut video it doesn't look lşke that. Any ideas ?







    thanks in advance for everyone who gives a hand
    Last edited by TAN_; 12-16-2014, 05:59 PM. Reason: Solved
    ArtStation

    General Development Blog

    #2
    One thing is GENERATED_BODY() defaults to private:. If you want the properties to be public, you have to use a public: identifier.

    EDIT: Or use Get() Set() functions.

    Comment


      #3
      Sorry couldn'T understand what you meant with that. Can you elaborate a bit ?
      ArtStation

      General Development Blog

      Comment


        #4
        Originally posted by TAN_ View Post
        Sorry couldn'T understand what you meant with that. Can you elaborate a bit ?
        Just after the GENERATED_BODY() add public:

        Code:
        ...
        UCLASS()
        class TUTORIALCODE_API APickup : public AActor
        {
        	GENERATED_BODY()
        
        public:
        	APickup(const FObjectInitializer& ObjectInitializer);
        ...
        Steam profile

        Comment


          #5
          GENERATED_BODY() defaults to private. Essentially there is a private: identifier at the top of the class. Try adding "public:" (without quotes) right below GENERATED_BODY(). Getters and Setters (GetX() and SetX()) are functions that you implement to be able to access private members. If you wanted to keep the class members private, you would create public functions that could get/set the values of your private members.

          Comment


            #6
            Yo mates. I tried what you suggested. But if I am not making a typo not working.




            By the way I just noticed my "...generated.h" file can't be read by the Visual Studio.




            I uncheked the "Read Only" in my main build folders' setting but still... nope.

            Man I gotta say. this is a real bummer. After all I was really excited about getting programming with UE4 and just turns out the official tutorials no longer works. Bummy bumming bummer.
            ArtStation

            General Development Blog

            Comment


              #7
              There is no generated header because the header tool is choking on your header file. According to the clipped error message in your last screenshot, "Unknown variable specifier VisibleDefaultOnly". Change that keyword to VisibleDefaultsOnly and see how it goes.

              Comment


                #8
                You meant this right ? ( sorry for being a noob) I chnged each one to Defaults



                Now I have more errors. Like +4 more.
                ArtStation

                General Development Blog

                Comment


                  #9
                  Originally posted by TAN_ View Post
                  Now I have more errors. Like +4 more.
                  Does the generated.h file get created, though? If so, that means progress! Instead of the Unreal Header Tool throwing errors, you're up to the actual C++ compile. That's a pretty typical thing in C++, more errors does not necessarily mean you're worse off.

                  Comment


                    #10
                    Should it be here ? ( By the way thanks mate, for staying here and helping)

                    ( TutorialCode is the name of the Actor that is created and C:\UE4 is the folder that my engine is located)

                    Click image for larger version

Name:	156.JPG
Views:	1
Size:	55.5 KB
ID:	1062213
                    Last edited by TAN_; 12-16-2014, 03:05 PM.
                    ArtStation

                    General Development Blog

                    Comment


                      #11
                      I went through this tutorial myself a few days ago. There are a few changes in 4.6 (which I tried to add to the wiki series here).

                      Here is my header file code, which compiles without any errors in 4.6:
                      // 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_API APickup : public AActor
                      {
                      GENERATED_BODY()

                      public:
                      UPROPERTY(EditAnywhere, BlueprintReadWrite)
                      bool bIsActive;

                      UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly)
                      class USphereComponent* BaseCollisionComponent;

                      UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly)
                      class UStaticMeshComponent* PickupMesh;

                      UFUNCTION(BlueprintNativeEvent)
                      void OnPickedUp();

                      APickup(const FObjectInitializer& ObjectInitializer);
                      };


                      CPP file:
                      // Fill out your copyright notice in the Description page of Project Settings.

                      #include "TutorialCode.h"
                      #include "Pickup.h"

                      APickup::APickup(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
                      {
                      bIsActive = true;

                      BaseCollisionComponent = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("BaseSphereComponent"));



                      RootComponent = BaseCollisionComponent;

                      //Create the static mesh component
                      PickupMesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PickupMesh"));

                      PickupMesh->SetSimulatePhysics(true);

                      //attach the static mesh component to the root component
                      PickupMesh->AttachTo(RootComponent);

                      }


                      void APickup::OnPickedUp_Implementation() //<--this is a Blueprint Native event, so we need to add _Implementation
                      {
                      //there is no default behavior for a pickup when its picked up.
                      }

                      Comment


                        #12
                        No, since the generated headers are regenerated on the fly and you are not meant to modify them, they are therefore treated as an intermediate file and kept separate.

                        If the header tool worked properly, it should say so in the build log. And you can reach the file (if it was created) by right clicking the include directive and choosing "Open Document", I believe.

                        Comment


                          #13
                          Ok copy/ pasted your code entirely. Clearly something wrong on my end.

                          Can you tell me if the place where we get our engine build matters or something ? Or any idea why some people just can not compile their created classes like this ? Anything works at this point really.


                          Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	167.8 KB
ID:	1062214
                          ArtStation

                          General Development Blog

                          Comment


                            #14
                            Can you post the list of compiler errors you're getting?

                            For what it's worth, I just used the default out of the box version of the engine.

                            Comment


                              #15
                              For some reason it started working ????

                              What daa.


                              All mates thanks a ton for your efforts.

                              Maybe we should get this to a sticky or something ?

                              Cheers
                              ArtStation

                              General Development Blog

                              Comment

                              Working...
                              X