Those two yield invalid pointers after reload. Note that I assign these pointer in Editor mode, without using Play at all, as part of tooling for building levels. Is there a property keyword I’m missing?
Do you mean a pointer to an object in the world? Typically I set it to EditAnywhere in the UPROPERTY macro. From there I assign the pointer to the object from the editor properties panel with objects that are placed in the world already.
Yes, objects in the world. Interesting that this works for you, I’m pretty sure my first attempt was with a full-blown (EditAnywhere, BlueprintReadWrite, Category=blah). I’ll try it again when I get to my machine.
Ok, you are right, this works now, but only for AActor*, not for Component*. There must be a pointer patching mechanism that only works for some types of objects. I generalized my question a bit too much, I’ll edit it to say Component only.
Thanks, but yeah the Component already exists, it is owned by an actor also in the World. I hacked my solution by storing both the Owner pointer (an AActor* will serialize properly) plus the name of the Component I’m after (since they are unique in a given actor). Then I got a dumb method that iterates through components until it finds the one with the same name.
This is Editor code, so it will not affect game runtime performance, but I’d like a better solution.
There are many ways to query your Actor for a component it may have. For instance, if you have (an know you will always have) one component of a certain class type, why not just use the following methods listed here in the documentation listed below?
So for the actor pointer you could call UActorComponent* OtherComponent = OtherActor->FindComponentByClass(); Where UActorComponent can be a pointer to any object, or object of a class deriving from, UActorComponent.
Yes, but I’d still like an answer to this question, as my solution is not the answer to it Or at least other devs looking for that answer will see there is none yet.