Announcement

Collapse
No announcement yet.

Melee weapon selection: Bool or Array?

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

    Melee weapon selection: Bool or Array?

    Hi, I was making a blueprint, but when I realized that for every weapon in the game ther's a 'Select'' animation, I trought:
    inizializing a 'Select Animation' bool for every weapon, won't be wrong?
    After All, Bool, is a variable type, then It uses memory.
    Creating then a various bool for every state is excessive(I think).

    In this case is better use an Array?

    I made Draw, Idle, Jump start, Jump loop, Jump end, Attack01/02/03, Attack 04 Charging/Idle/Release and Walk.

    Also I now need to know how scripting with Blueprint this Axe (So it can do all the action above) and managing the various animations.

    Some help?
    Thanks.

    #2
    You can also use enums for that. Have a bool for the Selecting state, and have a enum that is set to whatever weapon is being used, then you can use a blend pose node to select an animation to play depending on what weapon it is. I forget the exact name of the node, if you have the enum in your anim blueprint you should be able to find it. This way the state themselves are generic, and just selects an animation within it.

    edit: It's BlendPoses([Your Enum's Name]). You'll have to right click on the node after you've placed it to add pins for each element in the enum.
    Last edited by Mosel3y; 10-26-2015, 08:12 PM.

    Comment


      #3
      Err... About Enums, there are a lot of types.
      Which I should use?

      Comment


        #4
        You'd have to create your own, in the content browser right click, scroll down to Blueprints, and then click "Enumeration", then you can give it a name. Fill that enumerator with an entry for each of your weapons. Then, you can add a new variable to your character and anim blueprint of that type.

        Comment


          #5
          Which blueprint I should insert this enum?
          Actor? Pawn? Character?

          Sorry, but I'm just touching now the bases of UE4.

          Comment


            #6
            You should have it in both your pawn and the anim blueprint.

            You would set the value in your anim blueprint from the value in the pawn using Get Pawn Owner, and casting to your pawn, as below: (this is the anim blueprint)

            Click image for larger version

Name:	XjLc89V.png
Views:	1
Size:	104.8 KB
ID:	1092030

            Then you can use it like this (in the anim blueprint still):

            Click image for larger version

Name:	bpZjGKN.png
Views:	1
Size:	100.6 KB
ID:	1092031

            Say you had a shooting state, depending on what weapon was active in the pawn, it would switch to use a different animation here

            Comment


              #7
              Mmh... I'm nearly here.

              Only some explanation:

              In the first pic, what "Target Active Weapon Pawn" needs for? What is it? And what is its name in the library?
              In the second pic, What reroute nodes need for? How I can use them?
              Because I'm still not understood it.

              Ah! In the first pic, I can't see where the execution go to.

              Comment


                #8
                If you've got an ActiveWeapon variable in your pawn (or whatever you called it), you can get it in your anim blueprint by casting to it, and dragging off from the result, if you type in the name of your enum it will show up in the list, it's a getter for that variable in your pawn. That's what that node is in the first picture, it's getting the enum from the pawn.

                I've just got the reroute nodes to show you where you would put your animations, if you right click you can place animations and plug them in there, so a different one will play depending on what weapon you are using.

                Obviously, you need to actually set ActiveWeapon as something in your pawn, so if you switch weapons, it sets the enum too.

                regarding where the execution goes, that will depend on what you have in your blueprint right now, I'm just showing you an example for how to use an enum to do what you described in your question. It should fit into your anim blueprint easily.

                Comment


                  #9
                  Ok, thanks so much!
                  One last thing, why We have to insert the blueprint of the first pic, inside an animation blueprint?
                  Try to get Pawn Owner seems to be avaiable only in the animation blueprint.
                  Why?
                  Last edited by PainBoy; 10-27-2015, 04:47 PM.

                  Comment


                    #10
                    Think I accidentally deleted my reply....
                    I presume you are controlling your animation using an anim blueprint? Try To Get Pawn Owner is only available in an anim blueprint. An anim blueprint is the easiest way to do this, I presumed that was what you were using.

                    Comment


                      #11
                      There are other some errors I don't know how to fix. But Don't worry, I am trying to fix them and If I'll have some problem on this, I'll open another one thread.
                      Thanks very much!

                      Comment

                      Working...
                      X