Things You're Not Supposed To Do™

Hello dev friends!

This past week saw me and my team hit a bug in our project that got me thinking.

We’ve overriden the [FONT=Courier New]SetCollisionProfileName in our capsule component subclass to multicast to clients. Can’t remember when this happened, but fair enough, doesn’t seem too bad. The issue arises from Character’s constructor, which sets the profile on it’s capsule thus triggering the RPC. Since the character has not been replicated before (it is in the middle of its constructor!) its initial serialization happens. If you check in Character.cpp you can see that [FONT=Courier New]SetCollisionProfileName is called before the capsule is set as the root component, thus a location/scale/rotation of [FONT=Courier New]0,0,0 will be written for replication, and the scale will not be re-replicated on its own, after the root is set, so now our client has characters with 0 scale, resulting in interesting behaviour to say the least.

I simply solved it by doing some reasonable checks in the multicast to defer the remote call until the Actor is actually ready to roll. I also added an ensure to DataChannel.cpp so that coders get a break when a not-yet-initialized Actor is about to get serialized for replication.

Takeaway lesson (obviously): Do not replicate an Actor during its initialization. :rolleyes:

So to the gist of this thread: Where is the list of things you’re not supposed to do. Let me in on the secrets Epic! :slight_smile:

Surely y’all in this forum have come across a bunch of similar stuff.