Changing Character model

leeheo72

New member
This question has been answered in the previous thread. However, I wanted to know if it's possible to use a different avatar/skeleton. When I change the character avatar through code, everything except the character mesh sinks slowly (shown in the picture), and the weapon system stops working. Even after switching back to the original character avatar, it is still messed up. (sinking rigid body, and everything else comes back) Any thought or solution to this problem?

Thank you.
 

Attachments

  • Screenshot 2022-03-25 211937.png
    Screenshot 2022-03-25 211937.png
    227.3 KB · Views: 10

ChristianWiele

Moderator
Staff member
Does this work on a non-UCC character, i.e. just a skinned mesh with animator? I have never tried switching this at runtime.
 

leeheo72

New member
It works in Unity provided 3rd person controller. It doesn't have a weapon system, but all other controls are working.
 

Justin

Administrator
Staff member
It doesn't look like you are rebinding the bone references correctly. It's an involved process to switch out the references so I instead recommend using the prefab variant system or using the Character Builder to dynamically create a new character at runtime. This process has been improved in version 3 of the controller but it's not an easy change so I can't backport it to version 2.
 

leeheo72

New member
Thank you for the response. Over the weekend, I managed to get the skeleton to stay in place. (rebinding the bone reference) However, the camera will still fall when changing the character's avatar. Any suggestions?
Also, would you please clarify on prefab variant system and create a new character at runtime? Where could I find the resources regarding those? Thank you as always!
 

Justin

Administrator
Staff member
However, the camera will still fall when changing the character's avatar. Any suggestions?
It doesn't sound like you are referencing the correct object within the CameraController component. Make sure the character and anchor are correct.

Also, would you please clarify on prefab variant system and create a new character at runtime? Where could I find the resources regarding those? Thank you as always!
Prefab variants are just the standard Unity prefab variants. You could have multiple characters all using the same original prefab. For the character builder option I recommend taking a look at the UMA integration as it shows how to build a new character at runtime.

With that said, if the only issue that you have now is the camera then I would continue down that route.
 

leeheo72

New member
Prefab variants are just the standard Unity prefab variants. You could have multiple characters all using the same original prefab.
It turned out the weapons system is attached to the rig(skeleton), and I can't switch rigs; else, the weapons system will stop working...
Is it possible to create two characters and switch between the two at runtime? It would be a lot simple that way.
 

Justin

Administrator
Staff member
Is it possible to create two characters and switch between the two at runtime? It would be a lot simple that way.
Yes, that's similar to the prefab variant or character builder approach. You can reattach the camera with:

 

leeheo72

New member
Thank you so much. I think I'm very close to solving the problem. reattaching the camera is working, but movement input doesn't work. How can I reattach movement controls?
 

mikelu

New member
Hi, i am looking for the same question on how to import avatarn during runtime, i have the same result after changing nolan avatar with imported avatar, Nolan avatar start falling. Have this solve yet? tq
 

leeheo72

New member
I've found the solution to the falling avatar problem. (Partially still work in progress)
1. Reassign the anchor to the changed character. Disable auto anchor and reassign it to the new model's head skeleton
2. Under character -> colliders -> capsule collider, the "second end cap target" Reassign to the changed character model's head skeleton
3. In my case, the changed character model seemed odd. It was fixed by adjusting Character IK
4. For the animation, I used animate override to implement other animations.
Horray, it works! However, animation does not register over the pun network; the weapon system is tied to the skeleton and will stop working after changing the model. This is what I have so far. I hope this helped.
 

mikelu

New member
I've found the solution to the falling avatar problem. (Partially still work in progress)
1. Reassign the anchor to the changed character. Disable auto anchor and reassign it to the new model's head skeleton
2. Under character -> colliders -> capsule collider, the "second end cap target" Reassign to the changed character model's head skeleton
3. In my case, the changed character model seemed odd. It was fixed by adjusting Character IK
4. For the animation, I used animate override to implement other animations.
Horray, it works! However, animation does not register over the pun network; the weapon system is tied to the skeleton and will stop working after changing the model. This is what I have so far. I hope this helped.
thanks,
i will try ur method to test out if it has better result.
i have stop the falling avatar problem by moving the Character IK initializedBones method away from awake(). Then i initialiasedbone set to true once my avatar imported into the scene during runtime.
For the animation thru pun network, i use punrpc to let other player to download my avatar. Animation are working on both player thru pun network. The only problem for me now is weapon equip, there are several forum mention about UMA integration, i am looking at it now. hope we can figure out something here.
May i know what ur use case? if u are trying to import NFT avatar during runtime, maybe we can work something out.

 

mikelu

New member
Yes, that's similar to the prefab variant or character builder approach. You can reattach the camera with:

Hi, may I know can character builder only modify my rig for example add items on right hand and left hand, reference bone, holder etc. Only specific on rig. I am importing my avatar at runtime and running pun network. I am not sure if building a character in runtime using uma script will it affect photon view Id and photon transform and animation. Replace the animator avatar look good on animation, just weapon system still stick to the old avatar, if character builder can target only rigging, maybe I can update my rig value to specific controller can make it work. Tq
 

mikelu

New member
update: i have modify some code in UMA script and loaded my avatar in runtime. weapon equip and animation all look good. Just some shaking camera movement which i temporary solve by swicthing to normal at animator.update mode. Now i have a problem on PUN2, my prefab has been instantiated with photonview, any guide out there on how to add all the pun component to my imported character during runtime? tq
 

leeheo72

New member
update: i have modify some code in UMA script and loaded my avatar in runtime. weapon equip and animation all look good. Just some shaking camera movement which i temporary solve by swicthing to normal at animator.update mode. Now i have a problem on PUN2, my prefab has been instantiated with photonview, any guide out there on how to add all the pun component to my imported character during runtime? tq
I'm trying to develop a game where players can switch avatar/animation during the runtime. Importing the NFT avatar sounds really cool! I am pretty new to the game engine and still trying to figure it out. Would it be possible for you to share weapon equipment and animation code? I'm still struggling with that case.

Now i have a problem on PUN2, my prefab has been instantiated with photonview, any guide out there on how to add all the pun component to my imported character during runtime?
Are you trying to create a new character? Pun components should stay the same when switching only the models.
P.S I think the staff members won't be replying to this thread. I would suggest starting a new thread to get staff member insights.
 

mikelu

New member
My case maybe a bit different from u, u can download the UMA script from https://opsive.com/downloads/?pid=923. There are 3 files i use, UMACharacterBuilder, UmaAbilityBuilder and UMA ItemPickup. i just copy the onCharacterCreated method from UMACharacterBuilder to my avatar loader script. then i remove all related to UMA. Mainly replace "umadata" to my own gameobject, for ur case maybe Transform i.e. onCharacterCreated(Transform data). then replace the umadata from UmaAbilityBuilder and UmaItempickup to Transform as well.

if u run the method onCharacterCreated with ur new character, it will add all the component on ur new character and setup ur rigging with items on right and left hand and other neccessary.

thanks, i will try again to replace all the component with new avatar and see if it work with pun2.

if u still cannot get it work on UMA script, i will paste my code here.

lastly, if u r not importing new avatar on runtime, can take a look at photon ownershiptransfer when u spawn new player from ur resource folder.
 
Top