Announcement

Collapse
No announcement yet.

Announcing Section #1 for Survival Game - Third-person Player Setup

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

    #61
    Originally posted by Tom Looman View Post
    You could be missing an include of #include "SWeapon.h" in the file of the inventory, or you need to change it to:

    Code:
    TArray<class ASWeapon*> Inventory;
    the "class" keyword is a forward declaration and tells the compiler it will be a class. There is a pretty good explanation on forward declaration on StackOverflow.
    Thanks, I'll fix it for forward declaration to fix the error. Just not sure why it work in the survival project code. It compiles just fine. even though I can't see any class ASWeapons prior to the TArray. Anyway, thanks.
    Last edited by Gibdion; 05-26-2015, 08:17 PM.

    Comment


      #62
      Originally posted by Tom Looman View Post
      1. I am using the same method as ShooterGame to handle jumping with some extra functionality.
      OK, maybe I'm missing something as the jump looks the same to me as how the character jumps in ShooterGame? Do you add more functionality to jumping in a later section (I'm only up to section 2 so far)? Could you point out where I can find this additional functionality so I can study the difference between what you are doing and what the default jump does in the Character Movement Component?

      Originally posted by Tom Looman View Post
      2. That is a very viable option! With the recent improvements to component editing this is an good alternative.
      How would this work with the ray tracing when testing if the player is looking at a usable object? Would you get the actor the player is looking at and then check if it has the usable component attached to it before proceeding? Sorry I'm new to UE4 so am trying to get my head around these concepts.

      Comment


        #63
        Originally posted by wilberolive View Post
        OK, maybe I'm missing something as the jump looks the same to me as how the character jumps in ShooterGame? Do you add more functionality to jumping in a later section (I'm only up to section 2 so far)? Could you point out where I can find this additional functionality so I can study the difference between what you are doing and what the default jump does in the Character Movement Component?
        I'm not sure what you mean. The jump does indeed do pretty much the same thing as ShooterGame, which in turn uses character movement component. So there there is not much to compare.

        Originally posted by wilberolive View Post
        How would this work with the ray tracing when testing if the player is looking at a usable object? Would you get the actor the player is looking at and then check if it has the usable component attached to it before proceeding? Sorry I'm new to UE4 so am trying to get my head around these concepts.
        It could check for an Interface on the traced Actor, which defines what functionality a class is expected to have. In this Interface it would be the Component, so we could check if the Actor has the Interface, and then call Use() on the component.

        I noticed there isn't a lot of information on C++ interfaces, the docs talk about Blueprint interfaces, the concept is the same though so it might be worth a read:

        https://docs.unrealengine.com/latest...ace/index.html
        https://docs.unrealengine.com/latest...ces/index.html
        Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-Source)

        Comment


          #64
          I have a question about this section. I just came in here, hoping to learn C++ coding for UE4, but I have a problem with the files.

          If I'm not mistaken, the CPP and H files you linked to at the start of the first section, already includes the code you have added for the other sections as well. If this is the case, then this tutorial will essentially only be accessible to people who were doing it from the very beginning. I mean, as of writing, just the character class is already about 1000 lines long. To me this is extremely confusing and already kind of overwhelming, as I am not certain what code I need to write to make this first section compile without any mistakes (for instance, I already have to take in account at least the base character class, considering it is what the character class is extended from, and I have no idea what functionality written in the character class is reliant on what included class).

          Is there any plan or way to make it so people that found these tutorials later (like me) can also follow along?

          Comment


            #65
            Originally posted by cridia View Post
            I have a question about this section. I just came in here, hoping to learn C++ coding for UE4, but I have a problem with the files.

            If I'm not mistaken, the CPP and H files you linked to at the start of the first section, already includes the code you have added for the other sections as well. If this is the case, then this tutorial will essentially only be accessible to people who were doing it from the very beginning. I mean, as of writing, just the character class is already about 1000 lines long. To me this is extremely confusing and already kind of overwhelming, as I am not certain what code I need to write to make this first section compile without any mistakes (for instance, I already have to take in account at least the base character class, considering it is what the character class is extended from, and I have no idea what functionality written in the character class is reliant on what included class).

            Is there any plan or way to make it so people that found these tutorials later (like me) can also follow along?
            You can jump back to previous sections using the individual Branches on GitHub, for example section 1:

            https://github.com/tomlooman/EpicSur...tree/Section-1

            I hope that helps you a bit in getting into the code, especially Character has grown a lot more than I had anticipated

            - Tom
            Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-Source)

            Comment


              #66
              Where do you assign your DefaultPawnClass?

              I couldn't see that anywhere in the code. And I know when I start I project from scratch, I can't get my character to spawn without defined. Am I missing another way?

              Comment


                #67
                Originally posted by Gibdion View Post
                Where do you assign your DefaultPawnClass?

                I couldn't see that anywhere in the code. And I know when I start I project from scratch, I can't get my character to spawn without defined. Am I missing another way?
                Specifying the default pawn is handled in the Game Mode. In this project, specifying the player pawn class isn't actually done in code. If you look in the Editor, there are two game modes DebugGameMode and SurvivalGameModeSetup, which both descend from SGameMode. The default pawn class from AGameMode is overridden in these two blueprints, which you can find in the Classes section of the Class Defaults tab.

                It's pretty common to create one or more blueprint subclasses of your C++ class. That gives you the flexibility to use either Blueprint or C++ (and easily move logic between them) and gives you the ability to use the built-in features of the editor when it makes sense. If he had wanted to set the pawn in SGameMode, it could have been done the constructor and looked something like this:

                Code:
                    DefaultPawnClass = SCharacter::StaticClass();
                if the character class you wanted to use was a C++ class, it'd be something like this:

                Code:
                	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnOB(TEXT("/Game/Blueprints/Characters/Character_BP"));
                	DefaultPawnClass = PlayerPawnOB.Class;
                (note - code typed in editor, caveat emptor, may not compile )

                In this case, it looks like Tom put his common logic into the C++ class and then the things he wants to change between debug and non-debug into the blueprint class (which is a good idea I'm going to steal).

                Comment


                  #68
                  Hi Jeff! Thanks for answering that is such detail

                  Our top-level character class is a Blueprint "PlayerPawn" (Meaning assigning SCharacter::StaticClass() in code won't give you properly set up character) I'd like to avoid content references in code whenever possible (I might still add this specific case to the code just to demonstrate that it IS possible to do)

                  - Tom
                  Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-Source)

                  Comment


                    #69
                    Thank you for the explanation.

                    What confused me is, section 1 of this project has the game mode set to the SurvialGameGameMode, which is the C++ class, not the blueprint class. And has the pawn was set to DefaultPawn, not PlayerPawn BP. For me, based on what you said, I created a blueprint class based on my empty game mode c++ class, and within the BP, I assigned all my items. I do like this method much better. Thanks

                    Comment


                      #70
                      Originally posted by Gibdion View Post
                      Thank you for the explanation.

                      What confused me is, section 1 of this project has the game mode set to the SurvialGameGameMode, which is the C++ class, not the blueprint class. And has the pawn was set to DefaultPawn, not PlayerPawn BP. For me, based on what you said, I created a blueprint class based on my empty game mode c++ class, and within the BP, I assigned all my items. I do like this method much better. Thanks
                      The map must have been set to override it to the BP variant through the map's World settings. Otherwise the game would have not worked.

                      - Tom
                      Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-Source)

                      Comment


                        #71
                        Nice tutorial. Thank you

                        Comment


                          #72
                          when i compile the code of section 1,there is a compile error about the func below
                          void ASCharacter::OnLanded(const FHitResult& Hit) override;

                          it seems that OnLanded isn't a virtual member function.

                          my engine version 4.8.2
                          i just don't understand.

                          Comment


                            #73
                            Originally posted by 有亦 View Post
                            when i compile the code of section 1,there is a compile error about the func below
                            void ASCharacter::OnLanded(const FHitResult& Hit) override;

                            it seems that OnLanded isn't a virtual member function.

                            my engine version 4.8.2
                            i just don't understand.
                            The API changed from 4.7 to 4.8, section 1 code branch and docs may still include some references to 4.7 (and should be updated to 4.8 once the project is up on Learn-tab) the complete download of the project has all updated code of 4.8. OnLanded is one of those functions that was altered in 4.8.
                            Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-Source)

                            Comment


                              #74
                              thank you.

                              Comment


                                #75
                                I had a thought, based on outline material, how does one fix it so different types of objects have different color outlines?

                                I assume we create a MID maybe for types of objects. A bomb type for example could have a red color, Food would be yellow. Then in the ray cast, we create the MID and assign the color from the object? I've not worked much with MID, so am I even on the right path?

                                Just not sure how to access the blendable material in the PP volume through code
                                Last edited by Gibdion; 07-25-2015, 07:18 PM.

                                Comment

                                Working...
                                X