Cast to actor failed

The property you are trying to cast to StartRoom(which is called startroom).
Since you said it is in fact an invalid pointer, threre are two possibilities, either you are assigning an invalid value(most likely null/None) to startroom or by the time your cast runs your startroom object is destroyed and we need to see the assignment BP ( and any other related BP) to actually find the problem here.

Could be my fault for not using BP specific language but I meant I want to see parts of your BP where you use the “Set startroom” node. Basically where you change the value of startroom from the default none to something else.

i havent used it yet… but i cant set it to “startroombp”

So you never set it anywhere in your BP??
Try deleting it and adding it again and see if it fixes it.

has it something to do with this?
Screenshot 2023-12-01 191009

I’m very confused to say the least lol.
Let me summarize. You have a node of type actor object reference and you never set it to any value in your BP(or anyother BP) . You also can’t set it the BP of your StartRoom?
Is everything correct here?

Also a question, how exactly are you trying to set it to the BP of your StartRoom?

Ok that answers my question. Default values are set during object construction so yea you can’t change the default unless it’s a primitive type(or some containers like maps/arrays or anything else accessible at that point) . What you need to do is, set startroom to your StartRoom object at the begin play of your actor or anywhere else that works for you

so the blue print with the cast to is only spawned after a certain time, so i cant set the startroom to a value?

The initialization process of UE is quite complex but to say simply, yes you can"t set a default value for it. You should be able to set it at begin play or after that though and you should do it.

how should i tell my blueprint to doe something after start which it doesnt show before start?

Instead of using that variable, just use a ‘get actor of class’ node for your startroom :slight_smile:

Then you don’t need to cast either.

:clown_face: :clown_face: :clown_face:

1 Like

Meanwhile, here’s how you can set that variable

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.