Announcement

Collapse
No announcement yet.

[HELP] Drop Weapon and Remain amount ammo

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

    [HELP] Drop Weapon and Remain amount ammo

    So this is how i drop my weapon



    When i shoot with the gun and i used all bullets there is no ammo left.
    But when i pick it up again it resets ammo amount and i have again max ammo

    How can i solve this , that it remembers the amount of bullets

    #2
    **WHY PICK ISSUE**
    The reason you have max ammo value after you pick up the item is because you hard coded the value

    BP - 1
    GUN - m4a1
    AMMo - 35

    shoot-> 35 bullets
    dropgun-> Loop back to BP - 1

    gun-> m4a1
    ammo-> 35

    As you can see your stuck in a endless loop

    ** FIX **
    So you didn't show us the Blueprint to the ammo counter but doesn't matter.

    To do this you need to grab the last ammo ammount you shot and apply it back to the base ammo variable where you set the ammo counter..

    Comment


      #3
      your stuck in a endlless loop because you hardcoded the max ammo number everytime you recall the gunBP you just restting the ammo counter with the max ammo variable.


      To fix this you have to create a value that grabs the last ammo count and apply it to your ammo counter.

      Comment


        #4
        Originally posted by SunFluxGames View Post
        your stuck in a endlless loop because you hardcoded the max ammo number everytime you recall the gunBP you just restting the ammo counter with the max ammo variable.


        To fix this you have to create a value that grabs the last ammo count and apply it to your ammo counter.
        Thank you! it helped

        Comment


          #5
          You should set a bool or enum that set the gun's state and set the amount of rounds depending on the current amount attached the gun. You might have to refractor.
          I'm going to write this in semi-psuedo code logic

          So, unused gun picked up by player sets a bool of isUsedByPlayer = true, or enum state of gunUserState = GunUserState.helpByPlayer and set the gun player.roundsLeft = gun.roundsLeft
          Then, once dropped set gun.roundsLeft = player.roundsLeft

          That should work.
          Last edited by Kinos141; 08-31-2017, 04:56 PM.
          Check out my itch.io page, I'm really excited about it.
          https://kinos141.itch.io/

          Please check out my AI package: Action AI System Feat. Stealth
          https://www.unrealengine.com/marketp...m-feat-stealth
          or get it from itch
          https://kinos141.itch.io/action-ai-system-feat-stealth

          Comment


            #6
            Originally posted by KinDaKreator View Post
            You should set a bool or enum that set the gun's state and set the amount of rounds depending on the current amount attached the gun. You might have to refractor.
            I'm going to write this in semi-psuedo code logic

            So, unused gun picked up by player has a bool of isUsedByPlayer = true, or enum state of gunUserState = GunUserState.helpByPlayer and set the gun player.roundsLeft = gun.roundsLeft
            Then, once dropped set gun.roundsLeft = player.roundsLeft

            That should work.
            Yes i kinda did it this way , thanx for u comment

            Comment


              #7
              Originally posted by Faronoz View Post

              Yes i kinda did it this way , thanx for u comment
              Can you show us how you did it?

              Comment

              Working...
              X