So I have a code which check with line trace if I look at object which I can move or pick up (I also have world dynamic in array cause my doors are not simulating physics until you bring a key to them) and if I do the icon pops up and the code works fine BUT I have a journal which updates and must show on screen but it doesn’t because I have remove all widgets in this code. So my question is how to remove only the pick up icon and not all widgets ? I already tried to replace “Remove all Widgets” with “Remove from Parent” but it doesn’t work for some reason.
And there is the code:
When creating the pickup widget, rightclick on its output and promote it to a variable.
And instead of removing all widgets, just remove the stored widget from parent.
@BDC_Patrick Tried as you said but unfortunately it didn’t work
Also I get this error
And I can get rid of this error if I create the widget itself earlier and but it still doesn’t work.
The reason for this Errors is, that the Variable is not holding any Widget, before it is created. So it tries to remove an empty Widget pointer.
You need to check, if the variable is a valid Widget, before removing it.
Before the Remove from Parent:
Take your saved Widget “Pick Uphand”.
Now rightclick on it and convert it to a Validate Check.
Link that Check between the branch and the remove from Parent, to make sure this Widget exists. If not Valid, do nothing.
@BDC_Patrick Did it and still the icon doesn’t go away. However the error is gone
yes, the reason is your trace
You try to trace for object types, that are common and could be everything.
So, you need to filter your trace results for specific Actors.
The first Question here is:
Are those Objects, your Player is able to collect, Child Classes of a Masterclass, or are they just individual actors for their own?
Last, would be complicated, since you need to cast for every object your actor could, perhaps be looking at…
First, will make things simplier for you, cause you just need to cast for one type of actor class.
So… I think you don’t want to add a ton of casts to just get your icon be shown…
So my first suggestion is:
Create a new Blueprint Actor (just an Actor class). Call it f.e. “ObjectBase”.
If you now rightclick on that blueprint in your content browser, you’ll see as very first item, the create Child class thingy.
Make sure that every object your player can collect, is a child of this ObjectBase class.
What you need to do now is:
If your trace result bool is true, cast the hit actor to ObjectBase.
If the cast failed… Your player is not facing a collectable Object…
If the cast succeeded, you can SHOW your icon Widget.
I wrote Show in Capital… cause this is my second suggestion:
Dont create and remove one and the same widget over and over again… Thats a waste of memory and processes…
Better:
Create your Widget once, perhaps in the PlayerController and only switch its Visibility to “Visible” or “Hidden”/“Collapsed”.
Btw:
A third suggestion… Since this all sounds like you want to create an Inventory System…
Look for Ryan Laley on Youtube… He has a good basic Tutorial for Inventory systems… Including the collecting of items…
Just learn from it and try to create your own tweeks here for your own system.
There are many ways to achieve this but you will want to look into how interfaces work for best, future-proof result. Here’s and example with an attached project:
@BDC_Patrick Good guess but I don’t want to create an inventory system. Also in my game you don’t really collect items instead you drag them around with you. I want to make horror game and want it to be close to Layer of fear gameplay wise. Here is what I have currently. The game will be simple cause it’s my first one and also that will be my graduation work
The main problem is that I want to create journal on top right corner and when character overlap invisible trigger it pops up and show next goal but because every tick I trace in search for objects and removing every widget it immediately shut it down and player won’t be able to see anything. And yes I make every item as individual actors and to show message “door locked” I just added cast for door bp and if it doesn’t simulate physics to show the message that it’s closed
@BDC_Patrick
This…I didn’t realize that I could do that instead and when I create widgets in event beginplay I can just use visibility. That fixed the issue and you helped me SO MUCH! Thanks a lot you are the GOAT!
Simply making change like that fixed the issue.
Once again thank you so much!