Code design issue using interfaces to interact with objects

Xeru98
Tue, 28 Apr 2020 18:37:12 +0000
UI

I’m working on a project where the user will have the ability to modify different properties on server owned objects. The current plan is to have all objects that can be interacted with implement some sort of interface that would allow the player controller to have the server change properties on them. However, the types of interactions are different depending on the object. I have one type of object where i could interact and change the mesh or i could interact and change the material. To work around this I could potentially pass in the FName of the UProperty being modified as well as a generic UObject and then leave it up to the object to unravel the change. However, I have a second kind of object where I’m passing in a struct. Suddenly the whole process breaks because UStructs are not UObjects.

Currently each object class has it’s own interface with it’s own set of interactions but as the number of differnet types of objects grows I can see this becoming a problem long term.

What would be the best way code design wise to if possible allow all of the interactable object to use the same interface without requiring the playercontroller to have any idea of the kind of object it’s operating on instead only knowing the pointer to the object and the new data getting passed to it.

1 post - 1 participant