x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Inventory System is Collecting More than one Item

I have made a pickup system that will display a widget that says "Press E to Pick Up" When the player is looking at a box which is around a particular item. This is done through an interaction cylinder attached to the third person character:

alt text

When the third person character overlaps with the specific item in the blueprints for this item there is a begin and end overlap event for the box. When the third person character interacts for this I placed a branch to check to see if what is interacting with the box from the third person character is the interaction cylinder:

alt text

If the branch is true it will set the value for the subclass for this actor and then open the gate:

alt text

If the end overlap event occurs this will close the gate:

alt text

When the player presses "E" the player will enter the gate. After this, the item will added to the inventory through the means of setting a variable in the blueprint and then adding a branch in a different blueprint and the actor will be destroyed.

alt text

The problem is that whenever the interaction cylinder is overlapping with multiple instances of this actor and the player presses E, all of those actors will be destroyed and added to the inventory. Is there a way I could change this so the player will only collect 1 instance of the actor if the cylinder is interacting with more than one?

Product Version: UE 4.14
Tags:
more ▼

asked Jul 11 '18 at 02:00 AM in Blueprint Scripting

avatar image

Alec R
75 1 1 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Well the better way is to not put any type of interaction collider onto the player at all. Use a raycast system to detect the object youre looking at directly.

alt text

Here You Have The Line Trace That Tracks What Object You're Looking At

alt text

Here is what the itemref variable is. A variable of the master item to store the info on what item you just picked up

alt text

Here is the master item, a basic blueprint actor, i went more in depth and have item data for each one with its own specific details but that's not needed for this explanation.

alt text

This way is a much simpler and a quicker way of tracking what object you're looking at.

pic1.png (147.7 kB)
pic2.png (295.0 kB)
pic3.png (36.4 kB)
pic4.png (411.6 kB)
more ▼

answered Jul 11 '18 at 08:28 AM

avatar image

NRichardsBus
1

avatar image Alec R Jul 15 '18 at 10:29 PM

Is there a way I could store this in the blueprint for the actual pick up item like I have done with the apple, or do I have to do it in the third person character. If I can how would I go about doing this because the way I have, is not working properly.

Sorry for the late reply.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

To do it using your current system of an interaction cylinder on the player, you could set a single variable on the player to he item that triggered it. That way it only has the var set to the last item to enter the cylinder because the next one to overlap overwrites it then when the player does the Pick Up action you destroy only the item that variable points to.

I think it is better to change your system however to make things less complicated.

You can also pick a random one that is within range.

Usually to manage multiple obejcts going in and out of overlap, I add and remove them from an array. then when it is time to interact the object, i can pick a random one from the OverlappedItems array I made. In that way you can make it random which one that is in range gets interacted.

more ▼

answered Jul 11 '18 at 10:41 PM

avatar image

mightyenigma
2.1k 13 15 8

avatar image Alec R Sep 05 '18 at 12:23 AM

I am very sorry for the late reply, I had just moved on to creating the inventory system at the time of your reply since this issue was getting a little repetitive.

"To do it using your current system of an interaction cylinder on the player, you could set a single variable on the player to he item that triggered it. That way it only has the var set to the last item to enter the cylinder because the next one to overlap overwrites it then when the player does the Pick Up action you destroy only the item that variable points to."

I am not 100% sure how to do this. How would this work in the blueprints by setting a variable on the player.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question