I have done rootmotion previously and all was working fine in listen server. Now, I decided to change to dedicated and it works partially…
It works, but only for male character… (the default character of the BP)
Would you help me please ?
The situation is the following :
In my player BP, I have my main mesh. Depending of the player choice, I change this mesh by one of my male character or one of my female character at launch. My male and female characters haven’t the same skeleton (the skeleton depend of the gender).
The default mesh of my BP is one of my male character.
The reason why it is not working for female (I think) is because when playing the montage anim that have rootmotion, the server just don’t know that I changed the main mesh by a female character. So it try to execute the female montage on the male body so it hasn’t the movement informations.
What is the solution ?
I am with a dedicated server so I can’t tell him to set is skeletal mesh since he can’t render anything. So what should I do ?
in addition to setting the mesh directly also set a bool/enum designating the selection of the player, and set that bool/enum to replicate then based on that bool/enum pick the Montage to play.
this should allow the player choice while still allowing to pick the montage based on the different Skeletal Rig.
this will also help with saving as you can load the “correct” Mesh based on the bool/enum instead of what I would think of having the player select again on each load.
The truth is that I have not a mesh per character, I simplified things but I have several armor elements that I combined with a merge mesh. At the end it is one entire mesh. But I have only 2 differents possible skeleton and I already have a bool replicate to know which is used.
But my problem is not with the replication, since everything is well replicated. The only problem that I have is that my dedicated server can’t do the node “set skeletal mesh” since it didn’t render anything (it just crashed when doing it). Before, with a listen server it was easy, but now with the dedicated I have not idea how I can set the skeleton use by a mesh in order to have my rootmotion working, withouth setting the mesh…
without pulling into C++ (to make the variable Replicate ClientAuthority) you can change the replicating bool to be an enum ESkeletonState SkeletonState I will use a Werewolf type logic
then in the ReplicationNotify for the enum use that to drive the animation state, for example:
in the Construction Script SkeletonState gets set to lets say SkeletonState = ESkeletonState::IsHuman (where the initial active SkeletalMesh would be that of the “Human”)
on the trigger of the transition command either the server is notified immediately then the server returns the new state of SkeletonState (by virtue of the RepNotify) to all clients to now be ESkeletonState::ChangeToWerewolf (this can have the issue of with a “bad connection” to the server a feeling of a delay in the action on the instigating client) or you start the transition on the Instigating client, then broadcast the transition to be replicated to the other clients (the Server and other clients will be out of synce on the transition state with an offset of latency steps, but the Instigating client will feel responsive)
because the server does not perform the animation of the transformation when the notification of the transformation starts have a timer start that is maybe .1 seconds longer then the animation (just in case of latency) that broadcasts the transitioned state ESkeltonState::IsWerewolf
if State security is a concern in the context of the Instigating client starting the transition event then you can have the Instigating Client check the SkeletonState midway through the transformation using like an AnimNotifyBegin run a compare to the current SekeltonState that it is still in the proper ChangeTo____ if it isn’t then set it to the correct Is____ or trigger swap again to the other transition animation. Keep in mind that on a incorrect packet/cheater this could have the effect of having a definite delay on the transition happening relative to the other clients.
I think my problem was unclear. I have no issue at all with playing the good animation, etc.
My issue is the following :
At launch, I posess a player (that have a default male mesh in it). I look inside the database to know if I am male or female and what are my clothes.
Then, according to what I found in the database, I construct the mesh with a merge mesh.
After that, I set the new mesh (and replace the male default mesh I had in the BP).
Then, everything is working well (for the montages etc, I already use my bool to know which anim I should use, and all clients see everything well).
Everything is working well. BUT before in listen server, my rootmotion on the animation was working well for all clients. Now, I switch to a dedicated server and things changed.
And the reason is that I can’t do the “set skeletal mesh” on the server. So, I do it for all clients, so everything is seeing the players well, but the server still have no idea of how I looks like.
And after all, that wasn’t a problem, the dedicated server really don’t care about it.
But when the player play a montage, for example an attack where I have some rootmotion, then it cares. Because who is moving the player for rootmotion ? The server.
And since the server still think that I am the male default mesh, if my character is a female it will not launch my anim and not give me the rootmotion info.
On the client side, I can see the animation, but not rootmotion (blocking).
But if I choose the male character, then everything is perfect, since the default mesh as the same skeleton as me, the server only think I have different clothes etc, but it doesn’t matter since it has by default the correct skeleton.
At the moment, I just have no idea what I should do to tell to the server “hey I change my main mesh but since you are a dedicated server I can’t set it for you, so could you at least change the skeleton so you will be able to perform rootmotion ?”.
I hope it is clear now I am sorry my english is not perfect.
is there an explicit reason the male and female options don’t have “the same” Skeletal mesh? (I say “the same” because even Unreal will allow for some tolerances to share Skeletal Rigs)
to share a Skeletal Rig:
the same number of bones in each chain,
the same name of bones in the chains,
the same “general” position of the default pose (this is probably the most nebulous of the criteria and can sometimes be random when it decides to work)
it could be possible to take both Skeletal Meshes into a 3D modeling program like blender, and take say the Male Skeletons and Map it to the female Model, then re-import the female model and it should allow you to just use the “male” animations.
if you want some animations to be say female specific then use the bool/enum in the play state.
if it isn’t feasible to have the 2 Skeletal Mesh options share “the same” skeleton/animations could the Server maybe be in charge of selecting the animation to play based on the bool/enum, and the value of the input received (this way it could apply to NPC Agents as well). that way the motion delta should be consistent even if it plays the “wrong” animation.
I was thinking about it too, since they both have a really similar skeleton.
But I am not sure it will works, I have more than a hundred of animations for each gender, and a lot of montage I created. I am just scary that it makes everything broken. Moreover my anims where not perfect since they was retarget and wasn’t made for my character at the beginning (on a lot of anim I had to correct hands, fingers etc…).
But anyway, I think I will copy my project and just test because I am quite desperate…
Another solution that I was thinking is to create two child actor of my BP Character, (one female one male) and then set the default mesh in it. At the spawn I will just have to know early if I am male or female, and then all should work.
It could be a solution.
I am not sure what I will do.
About what you said, the Server is already in charge of playing animation. The client send it the montage it would like to play and then the server play. But if for example my client tell him to play the female attack anim, in all case the server will never play it for himself, since it will found that the skeleton is not the same as the mesh it have. (Maybe I haven’t understand well what you said ?)
Thank you again for your help, I really appreciate
Ok, so I never found an “easy” solution.
I have created 2 child of my BP Character. In this childs, I changed the default mesh of the player (one with the male and the other with the female).
At spawning event I don’t spawn the BP character anymore but directly his children
Everything seems to work fine now !
The only problem with this solution is that you have to have as much children as you have of skeleton. I have only 2 skeleton (male and female) but if you have more you may need a lot of children.