Can´t cast to an actor - UE4 BP - unreal-engine4

I´m trying to cast to an actor inside a widget button so I can toggle the visibility of a specific part of the actor itself.
The problem is that I don´t know what I have o put on the object node to make the cast work.

You can do "get all actors of class" before casting, select the actor you want "Cranio" then from the array square output from "get all actors from class" drag out a "Get (copy)" and connect its output with "object" in the "cast to Cranio".
Look at the image to visualize.

Related

Can't pick StaticMeshActor from scene when I create variable of that type in blueprint, if the actor is from sub-level in Unreal Engine 5

I have made an blueprint and inside of it, variable of type StaticMeshActor (object reference):
When I create instance of this blueprint in scene, I get the drop-down for my “Test” variable with StaticMeshActor actors in scene (that’s correct).
But once I click on any of them (that are from sub-levels), field resets to “None” again. Same goes for picker icon from scene.
Is it bug, or am I doing something wrong? Is it even possible to select actor from sub-level?

UE4: Call a function from an another actor in parent class

I currently have a problem because I can't figure out how to solve the problem. I have an actor that is supposed to call a function in the other actor on the "Begin Overlap Event".
The other actors that can trigger this event are all based on a parent blueprint in which the function was also implemented. My first idea was to cast directly to the parent BP. But that failed.
Maybe you can understand better what I mean with this little graphic.
Do you have an idea how I can solve this?
you can't call function GetDamage() from the variable "Target" because it is AActor class - he doesn't know anything about a child's functionality.
if your overlapped actor ("OtherActor") is TowerBaseBP with the GetDamage then you absolutely can cast to it. You can do it until set "Target" (in this case need to change this variable from AActor to the TowerBaseBP), or cast until calling relevant function GetDamage().
check "OtherActor" on the ComponentBeginOverlap - Is it your child actor with the needed parent?
if so cast to the Parent class (not the child one) and set your "Target" variable (need to be Parent type);
then try to call GetDamage() from Target;
if you can't still call it, I have two suggestions:
a) check your child classes - maybe you overrided GetDamage() and
forgot to add CallToParent function;
b) carefully check "OtherActor", and "Target" from points 1-3;

UE4: Still spawning an object, even though I set it to 'Do not spawn'

I want to add an object reference to an array in unreal blueprints, but I don't want to spawn it in the level. Is this even possible?
I tried setting the collision override to 'Do not spawn'. But it still does...
Here is the code: https://blueprintue.com/render/dvdrvdws
I expected that the actor doesn't spawn, but the actual result is that it spawns.
This is wrong add the weapon class in the array(turn the array type to weapon) , now only spawn what you want and when you want from this array using a different function or as you see fit .

access a variable from level blueprint in unreal engine 4

I Have a variable that updates every time i move my cube in the level blueprint , now i want to access this variable from multiple class blueprints , what do I do , I tried casting to gamestate but didn't succeed , I am really new to ue4 if you could explain in details please
edit: sorry for not adding details ,
The var I want to access is an integer named cube_side that tells me what side the cube is on every time I move , all of this happens in the level bp , I want to access this variable to see what side the cube is on from other class blueprints ->
here are some details in a picture
I know it's not good to code everything in the level blueprint , but it's too late now , I only need to transfer the var cube_side to other class blueprints so the other object can change depending what side the cube is on.
Create an Actor Class for your logic/functionality. Then use Get all actors of class (choose your class) -> Get a copy -> get variable
Communication with the level blueprint is rather tricky in UE4, since they are not as persistent as e.g. the GameMode, and therefore shouldn't be accessed directly (Imagine older games like Final Fantasy where a new level was loaded every time you stepped outside a boundary, so relying on it could potentially break your actors or crash the game due to nullptrs).
It's a little hacky, but works:
Move the variable inside the cube-blueprint. Add an event dispatcher to the cube, if it is moved, call it and pass the variable in.
Select the cube in the editor, open the level blueprint, right-click, "add reference to selected actor" (the cube must be part of a blueprintclass, not only a static mesh dragged in, though), and bind the event dispatcher inside the Level BP.
Create a function inside every blueprint that needs access to the variable, which does whatever it should do, depending on the variable.
The custom event of the Level Bp (that was bound to the Event Dispatcher of the cube), needs references to all actors that have to work, when the variable changes and call each Actors function (you can get the references like you got the one from the cube)
Then, every time the variable changes, the Level BP is notified, the custom Event is executed and this custom event calls all the actor's functions.
Event Dispatchers explained
This is a huge wastage of functions/code, since you only need it for this one level and may never use it again. Avoid this in the future, by not relying on the level BP so much.
You can use GameStateBP to create and store all variables that you need in game, in GameModeBP create functions to get and set this variables via Get Game State function and then function Cast To GameState and then logic. After that from any blueprint access it using Get Game Mode -> Cast to you GameMode -> use your function to set or get data from GameState.

observable object in an Activity Diagram?

How can I draw an activity diagram for this use case below?
User opens a closeable window to view a live update of xyz-data.
Specifically, I want to show an object flow in an activity diagram, but the object is an
observable data-storage object (i.e., the GUI control is bound to this data and thus shows a
live view of the data).
It's still an object isn't it? You can either mark it by a special class (i.e. :ObservableDataStorage) or a Stereotype or Keyword (i.e. <<Observable>> : DataStorage). Or/and you can use a relation which is named "observes" between the observer and the observable.