What is the modify() function?

Hello,

The short question is the title :slight_smile:

But here is the context, in case it’s relevant.

I just spent about a whole day on the following problem:

When a rider dismounts its horse, i detach its rootComponent from a horse’s socket using GetRootComponent()->DetachFromComponent.

It works well on the server, but when i connect a clientafter the pawn has been detached, the pawn is spawned at the origin instead of its server-location on the connected client.

Now in the FDetachmentTransformRules, there is a boolean bInCallModify which is set by default to true.

When i set it to false, it works well. It took me 15 hours to find that by random trials/errors, so i’d like to understand what’s going on here.

This bool seems to force the call to a Modify() function.

But i can’t understand what this function is doing. The comment in the header says:

/**
 * Note that the object will be modified.  If we are currently recording into the 
 * transaction buffer (undo/redo), save a copy of this object into the buffer and 
 * marks the package as needing to be saved.
 *
 * @param	bAlwaysMarkDirty	if true, marks the package dirty even if we aren't
 *								currently recording an active undo/redo transaction
 * @return true if the object was saved to the transaction buffer
 */
virtual bool Modify( bool bAlwaysMarkDirty=true );

But i don’t know what this means.

So basically, when an actor is modified (which is the default, so maybe it’s important ?), it spawns at the origin on connecting clients, and when not, it spawns correctly.

Anyone care to explain (simply please) ?

Thanks !

Cedric

Hmmm, unfortunately, after more testing (takes time because i have to repackage each time for steam to work), it still doesn’t work, so Modify() isn’t the solution.

I’m still curious about what it means tho, because i use a lot of attach/detach.

Thanks

Modify stores a snapshot of the Object into the transaction for undo/redo purposes. I believe it will only work if the Object has the flag RF_Transactional.

1 Like