Announcement

Collapse
No announcement yet.

Blueprints for Gametype-Specific stuff!

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

    [TUTORIAL] Blueprints for Gametype-Specific stuff!

    Original Post:
    Is it possible to add some Blueprint code to a Weapon or Pickup so that it is removed in certain gametypes? I want to place a Keg or a Redeemer in my level and disable it on TSD to place the Overcharge pickup on that same spot. It would really suck to have to release a DM and a TSD version of the map just for that...

    This looks like the kind of thing that would be super-easy to implement via Blueprint, but I'm a total noob at it and don't even know where to start. Can anyone help out with this, or point me in the right direction? I'm pretty sure that many of the people working on TSD maps for Mapcore will find it useful.

    ---
    Solved + Tutorial!
    Starting from the help I got in this thread, I was able to modify some pickups and meshes of my map (DM-Batrankus) by using a bunch of different methods. Since I have seen the 'gametype specific stuff' question asked in the past, I thought it may be worth sharing my final Blueprint setups in a noob-friendly tutorial... so here it is!


    Detect the current Gametype:
    Pretty much the same Blueprint as the one provided by tidu in the post bellow (thanks! ). It makes the game compare the current gametype to Team Showdown (or any other gametype of your choice). We'll connect the 'True' and 'False' outputs to the next nodes explained in the tutorial, depending on the actions you want to execute if the current gametype matches your choice or not.



    The Class variable at the bottom could be a bit hard to set up if you're a Blueprint newbie. Just add a new variable and give it the name you want (for example 'UTGame Mode TSD', or 'GameMode TSD'). Then click on the icon at the left of your variable's name and use the search box to look for the gametype you want. Once you've found it, hover it and select 'Class' in the submenu.




    Delete Stuff:
    This is the easiest approach and the one I would recommend using as much as possible. You will add all the weapons, meshes and stuff you need in the level editor, and then use Blueprint to destroy the actors you don't want to be shown in a specific gametype. Only thing to bear in mind is to disable the collision and shadow casting of the actors that may be removed:



    The Blueprint for deleting stuff is extremely easy to set up. Just place the 'DestroyActor' node, connect it from the 'True' or 'False' output of the gametype-detecting blueprint, and pin references of all the actors you want to remove to it.




    Change Materials:
    This one is pretty straightforward too. I used it in my level to change the material of this U-Logo to a Health icon depending on the gametype. All you have to do is browsing the StaticMesh you want to reskin for the Material Index to replace:



    Rest of the work should be easy as pie. Set the proper Material, Material Index, and connect your StaticMesh reference to the 'Target' node. The intermediate node is automatically created by Blueprint.




    Spawn Static Meshes:
    If you want to spawn stuff instead of using the destroy method, things get a little more complex. Spawning StaticMeshes is indeed possible, but bear in mind that they will only be affected by Stationary and Dynamic lights, so lighting may not be as good as normal static meshes with Static baked light. I chose this method in my map to add a grate that blocks a pipe with an Invisibility powerup, just to make sure the bot pathing is not messed up. I think I could have used the destroy method instead, but this is worth showing in the tutorial anyway... :P

    First, place your StaticMesh in the level editor like a normal asset. Once it is ready, copy all its Transform values, and delete it.



    Now place an 'Empty Actor', and paste all the Transform values from the deleted mesh. You may also want to change the name of your actor to something more informative. In my case I labeled it 'GrateLocation'.



    Add a reference to your 'Empty Actor' to the Level Blueprint, as the Target of an 'Add StaticMesh Component' node. You can configure the materials, collision and other flags of the StaticMesh in the Details panel, but don't mess up with the Transform values since the Empty Actor is taking charge of that. Your Transform variable (in my case, 'GrateLocation') also needs to be {{0,0,0},{0,0,0},{0,0,0}} for the same reason. You can set the Rotation and Scale Values in the Transform variable if you want, as long as you reset them to defaults in the Empty Actor.




    Spawn Pickups (Health, Ammo):
    To spawn game pickups like health, search for a 'Spawn Actor from Class' node in Blueprint:



    But, before setting up the Blueprint, place the pickup in the level editor first like a normal asset, so we can know its Transform values:



    Then, create a new Transform variable in Blueprint (in my case, 'PickupLocation'), compile, add the Transform values from the pickup to the new variable, and delete the pickup from the level editor.

    The rest of the setup should be pretty straightforward. In the 'Class' pin, choose the type of pickup to spawn. I would also recommmend choosing the 'Always Spawn, Ignore Collisions' flag.




    Spawn Pickups (Weapons, Powerups):
    If you try the above method with a WeaponBase or a PowerupBase, it won't work. That's because we're telling the game to spawn the weapon base, but there is no way of configuring the weapon to use, which is 'None' by default, so the game spawns nothing. That's why I'm suggesting using the 'Destroy Actor' method as much as possible, but sometimes it may not work: If you're trying to add a Redeemer and disable it in Showdown, the game will replace it by another powerup before running the Level Blueprint code, so the Destroy Actor method doesn't cause any effect. There you will need to use the Spawn approach:

    To get this to work, search for the WeaponBase Blueprint actor in the Content Browser and Create a Child Class from it. Move the created file to your personal folders and give it a unique name (since I want to spawn a Redeemer, I'm naming it WeaponBase_RDM).



    Double click on the Child class and change the default value to the Weapon you want to spawn.



    Now you should be able to assign your newly created actor to the previous Blueprint code, and the weapon base should be spawning properly.




    And that's about it! Really hope someone finds this useful and we have some more gametype-specific stuff in further maps!
    Attached Files
    Last edited by TheGlecter; 09-07-2016, 12:25 PM.
    DM-Batrankus is out on the UT Marketplace! Enjoy!

    My UT Maps: | JB-Makoy (UT3JB) | JB-Fragtion2 (UT2004JB) | CTF-Opposite (UT2004) | VCTF-Antropolis (UT2004) |
    My Puzzle Levels: | Tetrobot and Co. | Portal 2 | Toki Tori |
    My Localizations: | Killing Floor |

    #2
    Hey, I have a couple answers for you:

    In the example below, the blueprint tests at the start of the game for the game mode. The "UTGame Mode Class (specify)" is a variable that you create and assign a value to. The variable will allow you to select a class from a list of available gametypes. The next variable you need to create is UTInventory Class. When this variable is set to None, you can assign that to the existing PowerupBase on the level and it will disappear.




    The keg is a bit different. I found a "Set Pickup Hidden" node that will remove the keg, but not the pickupbase (pad under the keg). But it effectively removes the pickup from the map. You would follow the beginning of the blueprint above and then set the keg to hidden if the game mode meets your conditions. I hope this helps! I recently dove into blueprints for my mapcore map and can say that it gets much easier when you are familiar with what nodes are available. Good luck
    DM-Nine | CTF-HolyOak

    Comment


      #3
      Cool, thank you very much! I will try it ASAP and report back.

      We're talking about the Level Blueprint, not a Blueprint Class, right?
      DM-Batrankus is out on the UT Marketplace! Enjoy!

      My UT Maps: | JB-Makoy (UT3JB) | JB-Fragtion2 (UT2004JB) | CTF-Opposite (UT2004) | VCTF-Antropolis (UT2004) |
      My Puzzle Levels: | Tetrobot and Co. | Portal 2 | Toki Tori |
      My Localizations: | Killing Floor |

      Comment


        #4
        Yep, in order to reference a specific pickup on the map you need to create the above in the level blueprint. A blueprint class would be a custom pickup actor that you would have to place on the map, which may conflict with some other UT things, maybe bot nav, I'm not sure. But this method is much easier.
        DM-Nine | CTF-HolyOak

        Comment


          #5
          ****... It didn't work as well as expected...
          - I got the Redeemer to disappear on DM, but Team Showdown keeps replacing it by the Invisibility powerup.
          - I couldn't get the 'Set Pickup Hidden' node to work at all (neither Keg nor Redeemer).
          - Found a 'Set Actor Hidden Ingame' that removes both the Pickup and the Base, which seemed to work for the Keg... but it was still grabbable.

          Had a little more success doing things the other way around: instead of placing the pickup in the first place, I made the Blueprint spawn the Keg with a 'Spawn Actor from Class' node only if the gametype is not TSD, SD or Duel. I'm pretty sure that bots wont even know that the Keg is there, but at least it works! I guess I could use this method for the Redeemer too, but I can't figure out how to assign it to the WeaponBase spawned by the Blueprint...

          BTW, do any of the variables have to be replicated for online play?
          DM-Batrankus is out on the UT Marketplace! Enjoy!

          My UT Maps: | JB-Makoy (UT3JB) | JB-Fragtion2 (UT2004JB) | CTF-Opposite (UT2004) | VCTF-Antropolis (UT2004) |
          My Puzzle Levels: | Tetrobot and Co. | Portal 2 | Toki Tori |
          My Localizations: | Killing Floor |

          Comment


            #6
            I am very interested in this subject too... but honestly, I don't understand anything of your blueprint. Tidu, would you mind taking a moment to walk me through it?

            Comment


              #7
              I don't understand at all what the Casting thing does, but the Blueprint is quite easy to understand apart from that: The first part of it gathers which gametype the current game is, and compares it with a specific gametype you assign to the 'UTGameModeClass' variable. If both gametypes are the same, the '==' condition is true, and the 'Branch' node will fire the 'True' path (nothing in this case). If the condition is false, the 'False' path is activated and the 'Set Inventory Type' node will change the Weapon/Powerup from a WeaponBase/PowerupBase to 'None', so it is removed from the game.

              You can find any node by right clicking on the Blueprint editor and typing what you're looking for. The Variables have to be created in the 'Variables' tab in the left column. Variables are usually numbers or vectors, but the ones used in tidu's Blueprint are 'UT Class' variables, so you will have to change the Variable type once created and type what you're looking for.

              To place the reference to the PickupBase, select it in a viewport and then right click on the Blueprint editor. If you have the 'Context Sensitive' checkbox enabled, you will be able to see an option to add the reference to it.
              DM-Batrankus is out on the UT Marketplace! Enjoy!

              My UT Maps: | JB-Makoy (UT3JB) | JB-Fragtion2 (UT2004JB) | CTF-Opposite (UT2004) | VCTF-Antropolis (UT2004) |
              My Puzzle Levels: | Tetrobot and Co. | Portal 2 | Toki Tori |
              My Localizations: | Killing Floor |

              Comment


                #8
                That's a pretty good explanation. The cast method is used to specify a child class or blueprint. I relate it to inheritance from programming. The Game State class is generic in the UE4 editor. You can create your own blank project and use this class. The UT project has a whole slew of inherited classes and one of them is UTGame State. This class is the same as Game State, but has variables specific to Unreal Tournament, like maybe time remaining, # players, etc. From here, we can access UT Game Mode Class to discover the gametype.

                It may sound like you have to know what's going on behind the scenes, but the blueprint editor holds your hand a lot. Like that Get Game Mode Class node "Target" will only accept a UTGame State so you kind of backtrack, search by keyword and find nodes that will produce the proper UTGame State for you. I really only figured it out by just messing around with it for a while. Try to create simple blueprints and work up from there.

                Originally posted by G.Lecter View Post
                BTW, do any of the variables have to be replicated for online play?
                Depends on how secure you want this to be. This blueprint doesn't need any server specific information to run because the client knows what the gametype is. But to take it to the extreme... if someone tried hard enough they may figure out how to spoof the gametype so that the pickup actually spawns for only them when it should just be None. A more secure method is to have the server determine the game mode and send it to all the clients. The blueprint would then act upon this trusted variable. Now things get a bit more complicated!
                DM-Nine | CTF-HolyOak

                Comment


                  #9
                  So with this blueprint, if the result is false, this item shouldn't appear in this game type, does that mean the weapon AND weapon base (assuming using it on a weapon) will not appear at all in the game? as if they didn't exist? Or would the weapon base be there empty?

                  Comment


                    #10
                    In the blueprint above, it will remove the weapon and the weaponbase. It's the same as placing a weaponbase in the level, the default Weapon choice is None. If you play in editor without specifying a weapon you'll see that it just disappears.
                    DM-Nine | CTF-HolyOak

                    Comment


                      #11
                      Thank you. I'm not the OP but I appreciate your answers.

                      Comment


                        #12
                        During the development of my level I played around with Blueprint and found out different ways to deal with gametype specific stuff and solved some of the problems I mentioned earlier in this thread. Thought it was something worth sharing so I turned the first post into a tutorial! I'm still a total Blueprint noob though, so I would love to hear some comments if someone else dives into this...
                        DM-Batrankus is out on the UT Marketplace! Enjoy!

                        My UT Maps: | JB-Makoy (UT3JB) | JB-Fragtion2 (UT2004JB) | CTF-Opposite (UT2004) | VCTF-Antropolis (UT2004) |
                        My Puzzle Levels: | Tetrobot and Co. | Portal 2 | Toki Tori |
                        My Localizations: | Killing Floor |

                        Comment


                          #13
                          Nice work! Moved over to the learning level design sub forum since tutorial.

                          Comment


                            #14
                            Cool, thanks!
                            DM-Batrankus is out on the UT Marketplace! Enjoy!

                            My UT Maps: | JB-Makoy (UT3JB) | JB-Fragtion2 (UT2004JB) | CTF-Opposite (UT2004) | VCTF-Antropolis (UT2004) |
                            My Puzzle Levels: | Tetrobot and Co. | Portal 2 | Toki Tori |
                            My Localizations: | Killing Floor |

                            Comment

                            Working...
                            X