I am trying to cast from a widget blueprint to an actor, but it doesn’t seem to be working. I have created an actor object reference to plug into the object input of the casting node and I feel like this may be the problem, but am unsure what the solution is.
For reference, I want the text to be invisible, unless the player is within a certain distance of and object (im trying to make a detection system that will increases the nearer the player gets to an object, so if anyone has any entirely different ideas on how to do this that would also be greatly appreciated).
so the idea is there are objects hidden underground. As the player gets closer to them, there is a bar that would fill up more and more the closer the player gets.
And this bar and text, the widget you’re showing - each artefact has its own? Or the player has one widget that shows how close they’re getting to something?
oh right sorry, the text was just a place holder as im currently trying to just make sure I can hide/show the widget as id like.
each artefact shares the same widget- the widget is actually created in an artefact detection actor that is essentially a place holder for the actual artefacts since you won’t be able to see them under the ground.
This is the blueprint for my “ArtefactDetection” actor. It measures how near the player is to it as well as which of each “ArtefactDetection” ref is closest.
I am looking to create a bar that increases/decreasees in how full it is based o how near the player is to the “ArtefactDetction” actor.
-For context, the goal of the game is to find an artefact under the ground (the “ArtefactDetection” actor) at which point they’ll have to answer a question. getting the question. right will allow them to unlock an actual artefact-
And flag it as Instance Editable and Exposed on Spawn in its details panel. You’ll get a new pin on the Create Detection WB Widget node where you can plug in the closest actor obtained by fetching a reference from the Out Actors with Closest Index.
You can then use this reference inside the widget.
does the widget really need to know the reference of the artefact actor? The widget’s job is to show the exciting UI bits - perhaps the widget should be told the distance to display and told how to behave rather than made look for actor refs and extract their data.
instead of using the Get All Actor of Class node, you could instead try:
Perhaps there is no need to iterate over 1000 artefacts? Perhaps we can find just the ones that are close by and only sort those by distance? This is irrelevant if you have 10, very relevant if you have 10k. For this, the artefacts (or their placeholders) would need to have some form of collision.
Is not referenced (bar the the viewport holding onto it). If you ever call this script again, you will orphan the existing widget and create a brand new one. Again, this may be utterly irrelevant, may you only need to detect the artefacts once or something else makes this widget obsolete.
oh right yh I get that bit.
Im unsure what you mean by “out actors”. Simply plugging the Closestindex variable into the create widget blueprint im assuming wouldn’t even allow it.
These are the actors you found and are now sorting by distance. Eventually you find the one that is the closest by distance, and its index. You can use that index to fetch the correct artefact reference form the Out Actors array.
Simply plugging the Closestindex variable into the create widget blueprint im assuming wouldn’t even allow it.
The widget needs an actor reference, not merely and index.
I was under the impression you wanted to access the artefact itself in the widget. But you want to just access the Detector itself. Pass Self here instead: