Why is casting so hard? plz help

every time my character dies I call this code here which is in my paper character event graph:

I also have some stuff in this event begin play in my respawn item box, which is just an invisible box in the stage that is supposed respawn an item at its location when you die:

apparently, after you die twice, the item either constantly respawns or just doesn’t respawn at all depending if it was picked up or not before you died the second time.
if you had picked it up, it just wouldn’t respawn.
but is you had NOT picked it up, it just constantly calls the respawn function so it would never go away.

why is this happening after you die twice and how do you fix it?

is a bit hard to visualize your problem for help.

if your spawn is erratic (sometimes spwans and others dont but you want to always spawn maybe you should be sure this setting is set to always spawn:

image

also here:

image

that NOTE says that you are casting a variable of the type of the cast…so cast is not needed (1 - will always succeed if the variable has something on it and 2- you can call respawn item function directly from the variable. no need to cast for exposing properties.

3 Likes

i have multiple actors with the same class of item respawn so i think that is what is going wrong with my code.


But somehow this doesn’t work…

Regarding the last pic, disconnect the wires, choose class first, then connect For Each.

Order does matter, the type does not propagate if the class is selected afterwards.

image

vs

image

Same nodes, different results.


Also, avoid plopping nodes down on their own, use the context sensitive nature of BPs → drag the data wire first, then search for stuff. Much faster.

1 Like

wow never knew order mattered! thx for the info!