Announcement

Collapse
No announcement yet.

Creating Plugin-Based Game Code - Sept 6th - Live From Epic HQ

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

    #31
    Hi,

    Thank you for giving us the ability to make plugins more easily than it was following the existing tutorials. They're kind of incomplete and confusing (though fully utilized and appreciated).

    First, I was wondering about the other plugin options (in the wizard). There are a number of different plugin types, but I am interested in the one that links-in external libs. Right now, I link my lib in through an engine module, but I'd really like to be able to do it on the project level. I created a plugin of this type and it spat out a bunch of stuff that confuses me. I was hoping that there was some information on how to take the example library and substitute my own. Additionally, I'd like to know more about the "Is Engine Plugin" option.

    Second, I was hoping to be able to provide two sets of c++ base classes. The two plugins (or sub-modules) would define the same classes and then the developer would decide which one they were using in their project. The two would be mutually exclusive, of course, so the same project could be built with either of my plugins being active. I tried doing this but UAT doesn't like the same class being defined twice -- even though only one of the plugins is enabled. This sounds a bit like the comments about plugins being included in packaging even though they aren't used/enabled. I was hoping that someone might have some ideas or that this capability was added in the future.

    Thanks again,
    Jin

    Comment


      #32
      i have a simple question about adding cpp file to plugin using editor
      as in the vedio,there is a option like this:

      and in my project,it's like this:

      so,whit's the tick to set up these thing.
      now,i just using editor add file to my project and then manually copy file to the plugin diretory,and it's very very unconvienent and easy to make things wrong!
      please help~~~

      Comment


        #33
        Originally posted by Jin_VE View Post
        Hi,
        Second, I was hoping to be able to provide two sets of c++ base classes...
        I just wanted to post my work-around. First, to be clear, I am trying to get the Client and Server to build with different implementations of the same classes. Here's what I did.

        I put both sets of classes in the same plugin. In the plugin ModuleRules class (*.Build.cs), I added a check of Target.Type. If it is either TargetRules.TargetType.Game or TargetRules.TargetType.Client, I call Definitions.Add() with a preprocessor definition. If not, I define a different one. Then I wrap all my classes with #ifdef or #ifndef statements that look for those defines.

        It works well enough, but it is still desirable that the build tools can't even see the code of plugins which are disabled.

        Cheers,
        Jin
        Last edited by Jin_VE; 10-22-2016, 05:12 AM. Reason: typo / clarify

        Comment


          #34
          Originally posted by 有亦 View Post
          i have a simple question about adding cpp file to plugin using editor
          as in the vedio,there is a option like this:
          ...
          so,whit's the tick to set up these thing.
          now,i just using editor add file to my project and then manually copy file to the plugin diretory,and it's very very unconvienent and easy to make things wrong!
          please help~~~
          Are you using 4.13? If so then it appears that the plugin was not set up correctly.

          Cheers,
          Jin

          Comment


            #35
            oh,i was just using 4.12.
            i update to 4.13 and check it today! and it works in 4.13!
            i dont kown it is a new feature in 4.13.
            anyway,thanks a lot!

            Comment


              #36
              So this has nothing to do with the plug-in but what if you did want to have a quest like kill 50 wolves? I mean, I guess I could have a state for each wolf killed but that just seems silly
              YouTube channel: https://m.youtube.com/channel/UC1qaQM1VnY441J5lCLCPMwg

              Comment


                #37
                Originally posted by Ispheria View Post
                So this has nothing to do with the plug-in but what if you did want to have a quest like kill 50 wolves? I mean, I guess I could have a state for each wolf killed but that just seems silly
                Yes, making a quest with fifty "Killed A Wolf" states would not be the best way to do it. Especially if there's anything else you can do during the wolf-killing part. What I would probably do is make a small subsystem for detecting repeated actions. So I might make a "Repeated Action Counter" class that looks like this (rough outline):

                Code:
                // This is off the top of my head, it might not even compile and definitely isn't complete.
                class URepeatedActionCounter : public UDataAsset
                {
                GENERATED_BODY()
                protected:
                /** This is the InputAtom that increases the counter. */
                UPROPERTY(EditAnywhere)
                USM_InputAtom* Action;
                
                /** This is the amount of times Action must take place to cause Result. Every time the correct InputAtom is given, this value decreases by 1. */
                UPROPERTY(EditAnywhere)
                int32 ActionsRemaining;
                
                /** This is the InputAtom that results when Action has happened ActionsRemaining times. */
                UPROPERTY(EditAnywhere)
                USM_InputAtom* Result;
                
                public:
                // Possibly add something here to turn this on or off, like a bool member variable or a virtual bool function.
                
                // A virtual function that receives InputAtoms. If the InputAtom given matches Action, ActionsRemaining is decreased by 1. When ActionsRemaining hits 0, this function returns the Result InputAtom.
                };
                So that's the class, then I'd have an array of these in the PlayerController or GameInstance or wherever you decide to put your quest stuff. Go to whenever a new InputAtom gets added and you loop through adding that InputAtom to all your quests. Wherever that takes place, you can loop through all RACs and add any InputAtoms they give back to you onto the end of your input stream.

                You might also want to consider a base class for this as you go on, depending on how complex you want to get. For example, this is fine for things that happen one at a time, like "kill fifty wolves", but not great for things that happen in large quantities, like "gain 5000 experience points" (you don't want to add 100 "got an experience" atoms for every 100-point monster you kill), and unusable for things that can go up or down during the quest, like "turn a 10,000 gold profit at the mining outpost" where the miners and soldiers you hire to extract and defend the gold are paid with that very same gold (and thus your "profit" value rises and falls constantly). So your function that takes InputAtoms would probably also want an int32 quantity parameter to accommodate that.

                Or, maybe you have a "kill fifty wolves" quest, but your game actually has "regular wolf", a "dire wolf", and a "werewolf", and rather than making all wolves give you two input atoms on death (a generic "killed any wolf" atom, plus another atom for the specific type of wolf), you would rather just make your quest accept each acceptable type of specific wolf atom. In that case, the Action member variable should be a TArray<USM_InputAtom*>. OK, now let's say dire wolves and werewolves count double. Now that TArray<USM_InputAtom*> should be a TArray<FInputAtomCredit>, where FInputAtomCredit is a USTRUCT (you could also make another UDataAsset subclass for this) that designates a set of atoms (TArray<USM_InputAtom*>, as before) and also says how many points those atoms give (int32). So now you'd have two entries, one with just the regular wold atom at 1 point, and one with the dire wolf and werewolf atoms at 2 points.

                As you can see, the functionality here can expand based on what your game needs. This is what makes a good argument for having a versatile, flexible base class. If you want to see how to make a base class retroactively and without ruining your existing functionality (AKA backwards compatible), watch the third stream in this series, where I do exactly that as I expand to fighting game input processing, changing how the state machine works, but still keep things in working order for the Quest game.

                I hope that helps to explain how you'd use this system in a few more cases. Thanks for your question!

                Comment


                  #38
                  Thanks bro, i'll try that out
                  YouTube channel: https://m.youtube.com/channel/UC1qaQM1VnY441J5lCLCPMwg

                  Comment


                    #39
                    So after correcting my code in Quest.h and Quest.cpp I successfully build solution but I did not get the "KnightsQuest" item?

                    Comment


                      #40
                      Hey guys,

                      First off, I really enjoyed the content and found it very informative. Keep it up.

                      I would suggest, however, that in the future you start with a working project and go through it function for function rather than copying and pasting from a word doc. This would end the endless amount of frustration that I endured and probably many others when after 2 hours the final bit of code wouldn't compile. Additionally it should go a bit faster allowing for more content or discussion on theory.

                      Comment


                        #41
                        Originally posted by BMoney View Post
                        First off, I really enjoyed the content and found it very informative. Keep it up.

                        I would suggest, however, that in the future you start with a working project and go through it function for function rather than copying and pasting from a word doc. This would end the endless amount of frustration that I endured and probably many others when after 2 hours the final bit of code wouldn't compile. Additionally it should go a bit faster allowing for more content or discussion on theory.
                        We're glad you enjoyed our content! About your suggestion, I agree, and it's something we're looking at for future streams. The big difference between the "fighting" and "quest" streams (from our end) was that the quest streams were planned to be a certain length, and we had enough airtime to do it. The "fighting" streams, both of them, were planned to be a certain length, but then our airtime was shortened due to factors beyond our control at the last minute. That meant that the first stream ended short of where we meant for it to end, leaving us with a rough starting point for the second stream, which then also ended unexpectedly quickly, before we could do the live code-fixing we would have needed to find the disconnect that caused the code not to react to the input properly. Fortunately, the downloadable project (the "real" version we showed during the stream) does work as intended, and the explanations given for how the code was designed and implemented were all correct. We just missed a step somewhere in the live recreation of the code, but it's nothing key to understanding the theory behind anything we were doing.

                        In any case, I fundamentally agree with the concept, and we're working on ways to show the iteration of the code concepts without relying on such delicate systems in real-time, but without becoming a complete "cooking show" where we just pop out a pre-made working project and fail to explain the fine details of how it was made. Thanks for watching and sharing your ideas!

                        Comment


                          #42
                          Originally posted by Richard Hinckley View Post
                          In any case, I fundamentally agree with the concept, and we're working on ways to show the iteration of the code concepts without relying on such delicate systems in real-time, but without becoming a complete "cooking show" where we just pop out a pre-made working project and fail to explain the fine details of how it was made. Thanks for watching and sharing your ideas!
                          Thanks I appreciate it. When I am doing presentations where things can go wrong I typically plan on only 75% content fill and then I add on 'bonus' content for if no problems were encountered, although the worst I have encountered is a server error when presenting to a client and quickly stating "Sorry that page is currently being upgraded".

                          Comment


                            #43
                            Sorry to necro this but link to assets from first post is broken. Can anyone fix/reupload them?

                            Comment


                              #44
                              Originally posted by Vertex Soup View Post
                              Sorry to necro this but link to assets from first post is broken. Can anyone fix/reupload them?
                              I suspect the hosting site was temporarily down or undergoing maintenance. I just went there myself and was able to download the file. Would you mind trying it again?

                              Comment

                              Working...
                              X