Can not set default value of object reference variable

I can not get my variable “newvar_0” to have it’s default value set to the object pawn “Dhunt_camera”. The only way i can get the variable to work properly is to click each instance of the object using the variable in the level and manualy set it’s value to the camera from the level. However, this will not work for an object that is spawned later since it can not find a default value.

However, this will not work for an
object that is spawned later since it
can not find a default value.

That is exactly the reason why you can’t set a default. The variable can not assure that this object exists during runtime. You need to get a reference from somewhere else (not a direct reference to the object by default or the level script). This can be achieved by spawning those actors, receiving them via “Get All Actors of Class”, overlap / collision events or by passing down a reference from somewhere else. That’s pretty much the very basis of object orientated programming.

I hope this helps a bit even though it does not actually solve your issue.

Cheers :slight_smile:

Thank you so much.
So i have it now set that variable to an array outputted from the get all actors.
It works so far, but will it cause problems later on?

Probably not optimal, but it works for now.

That really depends. It will reliably pick the same one but it might not always be the one you want. If there is only one instance no. This will not cause any issues. Otherwise maybe.