Announcement

Collapse
No announcement yet.

Weapon Swapping?

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

    Weapon Swapping?

    I've searched throughout the internet and the forums but all I found was switching between a weapon you have and one on the ground.
    Basically I'd like to know how can I switch between 2 or more weapons I already own, simply by clicking 1 or 2, or scrolling the mouse.
    So for example, I spawn with a pistol, and when I click 2, assuming I have the weapon, I switch to a shotgun.

    #2
    this is Basic programming :

    Have a variable as an index.
    By pressing 2 or 3 you Change this variable to 2 or 3.
    You can then Change your weapon accordingly to this variable.

    We don't have your Code so we can't know what you already have and what not.

    Comment


      #3
      Originally posted by Raildex_ View Post
      this is Basic programming :

      Have a variable as an index.
      By pressing 2 or 3 you Change this variable to 2 or 3.
      You can then Change your weapon accordingly to this variable.

      We don't have your Code so we can't know what you already have and what not.
      What I'm wondering is how I do the switch, if I just do an animation or have the weapons already attached to the player.

      I'm also using blueprints, not code.

      Comment


        #4
        You should do an Animation Montage that lets the Player put away the gun and pull out the weapon.
        You Need to use Anim Notifies to Switch Meshes.

        Comment


          #5
          I've been looking around and found this by another user: Click image for larger version

Name:	91691-help1.png
Views:	1
Size:	151.0 KB
ID:	1113851

          That seems simple though I'm confused on I do I set up the function, I got the Graph with the Byte input added but I don't know specifically on what I should link to.

          Comment


            #6
            So I've been trying to find a solution to this, I've managed to replicate the image above in how I want it, but it's obviously not working, I think because I haven't associated the enums with the actual weapons, any suggestions?

            Click image for larger version

Name:	F5QlAG0.png
Views:	1
Size:	338.3 KB
ID:	1113914

            Click image for larger version

Name:	VVYb5jG.png
Views:	1
Size:	241.7 KB
ID:	1113915

            Click image for larger version

Name:	9Jic0lM.png
Views:	1
Size:	73.8 KB
ID:	1113916

            Comment


              #7
              This is a good starting Point.
              drag off the enum pin and create "Switch over" node. You may want to Play different Animations for each weapon and also Exchange the Weapon Model in the Hand.

              Comment


                #8
                Originally posted by Raildex_ View Post
                This is a good starting Point.
                drag off the enum pin and create "Switch over" node. You may want to Play different Animations for each weapon and also Exchange the Weapon Model in the Hand.
                If you're talking about the "Weapon" node in the second image, when I drag it over and type "switch over" these two appear: "Switch on EOverlapFilterOption" and "Switch on ESimulationOverlap".

                Comment


                  #9
                  You did create an Enum for this, didn't you?

                  Search for "Switch over ENUM" where ENUM is your custom Enum.

                  Comment


                    #10
                    Originally posted by Raildex_ View Post
                    You did create an Enum for this, didn't you?

                    Search for "Switch over ENUM" where ENUM is your custom Enum.
                    You can see the Enum in the 3rd picture.

                    Click image for larger version

Name:	cwPXn27.png
Views:	1
Size:	250.9 KB
ID:	1113921

                    Comment


                      #11
                      oh, my bad.
                      It's Switch ON.

                      Comment


                        #12
                        Originally posted by Raildex_ View Post
                        oh, my bad.
                        It's Switch ON.
                        Click image for larger version

Name:	5mBzIJK.png
Views:	1
Size:	260.6 KB
ID:	1113922

                        I'm guessing now I have to connect these two to their respective weapons? Do I connect to the static mesh/skeleton?

                        Comment


                          #13
                          These Execution Paths (Pistol and Shotgun) now Need their own logic for switching.
                          Play an Animation that first puts the current weapon away and then Play the Animation that pulls out the desired weapon.
                          Change the current selected Weapon , Swap Meshes etc.

                          Comment


                            #14
                            So I've made some progress, but it's still not how I want it.

                            On the topic of animations, I don't really want those right now, I just want it to change immediately, no animation for it.

                            Here's the main function: Click image for larger version

Name:	EzPWloS.png
Views:	1
Size:	403.0 KB
ID:	1113934

                            Here's the Event Graph: Click image for larger version

Name:	K3c3LYE.png
Views:	1
Size:	404.9 KB
ID:	1113935

                            Now, if I start my character with just his hands (no weapon on it), and I press 1, the Pistol does show up, but if I press 2 the Shotgun doesn't.

                            There's one problem though, whenever I press one of the numbers, it adds one more weapon in front of me, so they overlap each other, I can have like 12 more items and they don't kill themselves after I press another button (so if I had a pistol and pressed 2 for shotgun, I'd want it to kill the pistol and summon the shotgun).

                            I suspect the shotgun doesn't appear because I don't have it in the skeleton like I have with the pistol, here's the error that shows up: Click image for larger version

Name:	vtaJQm1.png
Views:	1
Size:	499.6 KB
ID:	1113936

                            So, basically:

                            How do I kill the pistol when I switch to the shotgun and vice-versa?

                            How do I implement the shotgun in the same place as the pistol is?

                            Comment


                              #15
                              You only ever want to spawn each weapon one time and create a reference to each of those weapons . Then for weapon switching you simply hide one mesh and show the other .

                              So for example . You want pistol and shotgun . So first go into character and on the hand bone . Make two sockets that will be the spawn position of the different guns . Use a preview asset to position them accordingly and line them up .

                              Next in you're character make a function called spawn weapons .
                              Spawn each weapon and set its position to be the newly created socket positions . Drag off from the spawn node and set these in a variable which will be a reference to that particular gun . This is useful because you can use it over and over again whenever you want to do something with that gun .

                              Then make an enum . Shotgun , pistol

                              Switch on enum when you press 2 hide pistol mesh , show shotgun mesh , when you press 1 hide shotgun mesh show pistol mesh
                              Last edited by EniGmaa; 08-18-2016, 03:01 AM.

                              Comment

                              Working...
                              X