Announcement

Collapse
No announcement yet.

Inventory problems :(

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

    Inventory problems :(

    Hi
    I have been working on a smaoll project of mine and it contains a inventory system made from the tutorial done by Unreal on YouTube. when the inventory was completed i changed a small thing in the code, insted of makig the object invinsible and have no collider i disided to destroy the actor and spawn it when I either pick up the item or drop it.
    But when I try to drop the actor the object never spawns in the world what am I missing or doing wrong?
    Click image for larger version

Name:	ScreenShot.png
Views:	1
Size:	304.7 KB
ID:	1184987

    #2
    Hard to tell what's going on here without watching the tutorial or seeing more of your BPs.

    I'd say you destroyed the actor, which would mean that reference is not valid, so the get class node has no class to get.

    Try storing the actor's class in the inventory rather than storing a reference to the spawned actor (that's what the blue references are) before destroying the actor, then spawning the actor from the stored class.
    They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

    Comment


      #3
      Try printing two things after the Spawn Actor node: Print the Resulting actor reference (to be sure it was actually spawned) and print its transform. If your transform returns with a constant location whenever you move, there's something wrong with the Drop Location Reference

      Comment


        #4
        Originally posted by KorkuVeren View Post
        Hard to tell what's going on here without watching the tutorial or seeing more of your BPs.

        I'd say you destroyed the actor, which would mean that reference is not valid, so the get class node has no class to get.

        Try storing the actor's class in the inventory rather than storing a reference to the spawned actor (that's what the blue references are) before destroying the actor, then spawning the actor from the stored class.
        I see. Well if I took away tha whole spawn function It would then make the actor visible and the collider becomes active and tha new transform is at the DropLocation

        and it works for others but not me(wich is preatty od).
        another idea is that i put the drop function in the Item instead(the spawn actor function), What do tou think?

        Comment


          #5
          the print nodes said nothing when the drop function was called

          Comment


            #6
            For reference, can you post how you're picking up/storing these inventory items, and where you call drop from?
            They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

            Comment


              #7
              Click image for larger version

Name:	Skärmbild (4).png
Views:	1
Size:	386.4 KB
ID:	1107222Click image for larger version

Name:	Skärmbild (5).png
Views:	1
Size:	433.2 KB
ID:	1107223Click image for larger version

Name:	Skärmbild (6).png
Views:	1
Size:	369.6 KB
ID:	1107224Click image for larger version

Name:	Skärmbild (7).png
Views:	1
Size:	359.8 KB
ID:	1107221

              Comment


                #8
                Yeah, it's like I thought.

                Modify InventoryStruct to contain an item class, and on begin play call GetClass on self, use 'set members in struct' to set the class (purple) variable. Modify your Action Interface to take a class instead of a reference in "DropAction".

                In your UI, when you click to drop (I'm guessing this in in UI) instead of using the reference, just pass in the class variable. Then, in your drop functionality, don't worry about 'GetClass' and just Spawn Actor from the class itself.

                The problem is that when you store the item in item info, you're storing a reference to the spawned instance of your item class. The 'Destroy' node starts the destruction process, which won't be processed immediately (I don't think) so although you typically should call Destroy last- I don't think this is hurting your BP. Anyway, Destroy finishes pretty quickly and by the time you drop the item, there is no item at that reference- it's nullptr.

                You can test this by dragging the reference which is passed in and using 'IsValid' and printing a string depending on the result. Spawn Actor won't have a class to spawn, your print strings have no value to print. That's why the strings don't appear.
                They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

                Comment


                  #9
                  wait what was i ganna get from the self in the begining?Click image for larger version

Name:	Skärmbild (8).png
Views:	1
Size:	368.6 KB
ID:	1107230

                  Comment


                    #10
                    Get Class
                    Click image for larger version

Name:	3c6f36bed52c27e19534df6d4bc2c9b6.png
Views:	1
Size:	9.4 KB
ID:	1107231
                    They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

                    Comment


                      #11
                      wait like this?
                      Click image for larger version

Name:	Skärmbild (9).png
Views:	1
Size:	353.3 KB
ID:	1107232

                      Comment


                        #12
                        Originally posted by Grasan View Post
                        wait like this?
                        [ATTACH=CONFIG]95039[/ATTACH]
                        Yeah.

                        Now you'll want to update your interface to use a class for 'drop item' and then when you call 'drop item' (this is where you're telling the character what item to drop) you'll want to pass that class in, instead of the reference. Then, in the actual drop function, you'll want to just spawn actor from class.
                        They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

                        Comment


                          #13
                          okey this is wery od. I did all you said but when I pick up rhe item it wont get stored in the inventory menu + I changed the DropItem to a class
                          Click image for larger version

Name:	Skärmbild (10).png
Views:	1
Size:	343.3 KB
ID:	1107234Click image for larger version

Name:	Skärmbild (11).png
Views:	1
Size:	352.9 KB
ID:	1107236Click image for larger version

Name:	Skärmbild (12).png
Views:	1
Size:	327.6 KB
ID:	1107237Click image for larger version

Name:	Skärmbild (13).png
Views:	1
Size:	323.8 KB
ID:	1107238

                          Comment


                            #14
                            Originally posted by Grasan View Post
                            okey this is wery od. I did all you said but when I pick up rhe item it wont get stored in the inventory menu + I changed the DropItem to a class
                            Click image for larger version

Name:	76911ca774ec064aa89af34097f50ed3.png
Views:	1
Size:	100.8 KB
ID:	1107239

                            So this is setting your display text and icon to nothing. You need to either remove these from the node, or set the value in place.
                            They broke the signatures so I removed mine thinking it'd be awhile. The signatures work again, but I haven't redone my signature yet.

                            Comment


                              #15
                              I dont think thats the problem, i found that when the use action is called in the player hud, the target MUST be an actor not a class
                              any ideas. cus i have none.
                              Click image for larger version

Name:	Skärmbild (14).png
Views:	1
Size:	395.9 KB
ID:	1107244

                              Comment

                              Working...
                              X