Announcement

Collapse
No announcement yet.

Changing a class variable.

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

    Changing a class variable.

    I made a post on this a few hours ago but it was very badly worded and quite confusing. What i wanted to know is, is there a way where i can change my variable from one thing to another let me explain a bit more.

    Basically i want a umg widget button (there will be 3 buttons for all 3 of the guns) where the user can select between 3 guns says the three guns were called Ak47, Scar, P90
    if the player select the 1st option(AK47) it would change my primary weapon blueprint from the default weapon (Scar) to the ak47
    Then the default weapon would be the 1st option(AK47) and not the scar and this can be constantly changed so the player can keep switching between new guns

    Click image for larger version

Name:	weapon.png
Views:	2
Size:	8.4 KB
ID:	1204473

    #2
    This is a classic case for inheritance. You want all of your guns be child blueprint classes from the same class. Called for example Gun. You implement everything these 3 guns have in common in that class: damage, accuracy, amount of ammo... and you change the respective values of those variables in the respective gun. Now you change the type of your weapon variable in your character to Gun. Now you can easily modify the weapon class your character currently helds during the game.
    Twitter | Multiplayer TopDown Survival Kit | Fog of War | Game Stats Kit

    Comment


      #3
      Originally posted by Pepeeee View Post
      This is a classic case for inheritance. You want all of your guns be child blueprint classes from the same class. Called for example Gun. You implement everything these 3 guns have in common in that class: damage, accuracy, amount of ammo... and you change the respective values of those variables in the respective gun. Now you change the type of your weapon variable in your character to Gun. Now you can easily modify the weapon class your character currently helds during the game.
      I already have all that set up all my guns inherit from a Weapon_Instant. The reason i have primary and secondary is because i have a switching system. i was wondering if the primary weapon blueprint and the secondary weapon blueprint can be changed from umg widgets so if i click a button on the UI the primary slot will change from "Weapon_Scar_BP" to "Weapon_AK47_BP" so that why you can change your current gun in the game without having to change it manually.

      Is there a node for this in the Umg widgets to allow me to change a currently set blueprint variable
      Last edited by rapiidzz901; 12-24-2016, 09:03 AM.

      Comment


        #4
        I dont know if im terrible at explaining but i mean but this should be 100% possible to do.

        Basically i have a collection of guns. From a umg widget i want the player to be able to select their gun of choice..
        This is the umg widget i mean

        Click image for larger version

Name:	primary.png
Views:	1
Size:	14.3 KB
ID:	1120541

        Ok so the user has a selection of three guns say the player wanted their primary gun to be a Scar if they click the Scar button it will set their variable in the character class to the correct blueprint
        So if i clicked the Scar button it will set the primary gun to this

        Click image for larger version

Name:	scar.png
Views:	1
Size:	5.0 KB
ID:	1120542

        If the player wanted to change their primary gun to the KA5C if they click the KA5C Button it would again change the variable blueprint class from whatever their previous gun was in this case mine was the Scar to the KA5C like this

        Click image for larger version

Name:	ka5c.png
Views:	1
Size:	5.2 KB
ID:	1120543

        Then if the player wanted to change again they could select their gun they want and once again it would change the blueprint variable

        Click image for larger version

Name:	p90.png
Views:	1
Size:	5.1 KB
ID:	1120544

        How can i setup the buttons in the umg widget to change the blueprint variable automatically?

        Comment


          #5
          Any ideas? There must be a node to change this in umg widgets?

          Also how do i get my gun model in a umg widget just the gun without a background?
          Last edited by rapiidzz901; 12-29-2016, 11:56 AM.

          Comment

          Working...
          X