Using the Property system, you’d need to get the value, change it, and then set it again. This is similar to how Blueprint needs a “break structure” node to update a struct property.
That being said – you’re in C++. You can define an interface or object base class that has a property you can access as a C++ object, rather than through the property system. Get pointer to containing object, update field.X, done! It’ll also run a lot faster than going through properties.
Thanks for the reply. I’m trying to leverage the property system so I can dynamically find the exposed values of a UClass - and link them to data coming from a network interface that isn’t compatible with Remote Control plugin from Epic.
As you said a static approach using just c++ ptr to a UObject is much faster but it doesn’t offer the flexibility I’m looking for. With the property system I can find all the exposed UProperties dynamically on any UObject. Is there a better way to dynamically link something like incoming network data to a UProperty?
To be clear - I’m creating a user defined linkage, which is why finding and settings the property by name needs to be dynamic in some way. I’ll have to be able to query a UObject for all it’s exposed properties.
All I’ve been able to find so far is leveraging the property system, but thats straying away from the original question.
If you’re doing something like receiving DIS PDU packets, and trying to render objects in the world, then there are several better options.
First, Actors have a known location/orientation. Instead of using UObject, you could say that anything driven by your incoming packets is an AActor, which lets you use direct pointers.
Second, you could implement a custom interface, and query for that interface, and then send whatever update you need through that interface. Something like IUpdateReceiver and have it have a ReceiveUpdatePacket method, if the structure of the packet is known.
That being said – if the abstraction penalty isn’t a big problem for you, that is indeed a very decoupled approach. In that case, get the struct value, update the value, and set the struct value again.
Thanks for your insight. There might be some combination of an Interface and a known message structure that could work for all the knowns - but can always default on the property system if it has to. This was very fast very excellent information. I’ll mark it as resolved as soon as I can get it working.