How to SWAP your Character! (Change Mesh Visual, Same Animations, Controller)
Вставка
- Опубліковано 19 сер 2024
- 🌍 Get my Complete Courses! ✅ unitycodemonke...
👍 Learn to make awesome games step-by-step from start to finish.
👇 Click on Show More
🎮 Get my Steam Games unitycodemonke...
🔴 RELATED VIDEOS 🔴
Kickstart your game with First and Third Person Controllers! (FREE Unity Starter Assets) • Kickstart your game wi...
FREE Characters and FREE Animations for your GAMES! (Mixamo) • FREE Characters and FR...
POLYGON City Synty cmonkey.co/syn...
💬 Learn how to change a Character Mesh Visual while keeping the same Controller and Animations.
Here I am demonstrating that process using Unity's FREE Third Person Starter Assets Controller but these steps work on any character controller for swapping any character visual.
1. Change the SkinnedMeshRenderer
2. Change the Bones
3. Assign the new Avatar for the new Mesh
Make sure the Bones have the correct name!
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
✅ store.steampow...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🎮 Grab the Game Bundle at unitycodemonke...
📝 Get the Code Monkey Utilities at unitycodemonke...
#unitytutorial #unity3d #gamedev
--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.
I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Other great Unity channels:
Unity - / unity3d
Brackeys - / brackeys
Dani - / @danidev
Jabrils - / @jabrils
BlackthornProd - / @blackthornprod
Sykoo - / sykootv
Jason Weimann - / @unity3dcollege
Jonas Tyroller - / @jonastyroller
--------------------------------------------------------------------
- Website: unitycodemonke...
- Twitter: / unitycodemonkey
- Steam: store.steampow...
💬 Learn how to change a Character Mesh Visual while keeping the same Controller and Animations.
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
🔴 RELATED VIDEOS 🔴
Kickstart your game with First and Third Person Controllers! (FREE Unity Starter Assets) ua-cam.com/video/jXz5b_9z0Bc/v-deo.html
FREE Characters and FREE Animations for your GAMES! (Mixamo) ua-cam.com/video/c4jtyDA7vcs/v-deo.html
I've needed this so badly. Struggled real hard on how to do this for a while before just giving up. Great video!!!
An alternative that avoids the object naming issue is to drag in the prefab, unpack it (right-click on prefab instance, Prefab -> Unpack) and then drag the objects straight from the unpacked prefab instance into your character object.
Yup that also works!
Your Tutorials are so help full they have helped me out a lot
Hey I just recently got into Unity, learning purely as a hobby at this point. Just wanted to say you make some great videos! Thank you very much!
Thanks! I'm glad you like the videos!
I wonder how many times in my life the Root (1) threw me off and I didn't even know why it wasn't working!
I WAS JUST ASKING SOMEONE ABOUT THIS!
Dang, coincidence or not, thank you so much for uploading this
This summary of the points to check is very practical. Thank you !
great video, thanks! I’ve had many problems previously and didn’t realise it is just three steps
Super cool👍🏻
Thank you for sharing this with the Community, I was wondering how to make this in an easy manner, and your video just came for the rescue 🙏🏻💥😆✌🏻
Thank you for this tutorial! Just got som of synty's assets and this was super useful!
Exactly when I needed them. You have perfect timing as always.
I’ve been waiting for this tutorial!!!
I hope it helps!
ATTENTION as you drag your characters in the scene , unpack them with right click on prefab hierarchy(scene), and then unpack Prefab -> Unpack. This will allow to copy easily mesh and rig from your character to first person controller.
Obrigado Code Monkey! Não sabe o quanto me ajudou!
Nosso projeto sairá do papel muito mais rápido agora 🤝👏
Nice! Boa sorte com o projeto!
Thanks :)
Just when i needed lol!
Thanks for the quality content you offer with your tutos ! Many of your videos are about FPS, so what about a tutorial of using Miror of how to set up a multiplayer network ?
I plan to cover Multiplayer when Unity's MLAPI (NetCode for Game Objects) comes out of preview
Congrats for your unity award
Teacher
great video! i noticed no one ever makes tutorials for serious/educational games (like typing games) that are any good. (Probably because theyre boring) but those would be a huge help for students! just a thought. thanks!
I enjoy some typing games like Typing of the Dead but yea it's a hard genre to make exciting on a UA-cam video
Yeah I'm in my last semester and we have to make a super simple typing game. I've been able to do it but just barely. I find keeping my code organized when I have object pooling to be kind of difficult, but I'm also not really a programmer.
I remember playing Typing of the Dead as a kid, that was fun.
Thank you
nice tutorial, I have some things i want to say:
1.does this also work on characters with different size, the characters you use have identical size/scale will it work if i want
to change from(Goblin to giant) characters with different size/scale.
2.does such result can be done through Code example: my game character is a wizard that have the ability to transform to any creature in the game, can i do those steps by coding(i already done those kind of tasks but asking for more knowledge won't hurt).
3. can we apply the SkinnedMeshRenderer Component Step to a MeshRenderer?
thanks for your help i hope I'm not being anoying
1. Size should not be an issue. - Best way to figure it out is by loading up Unity with some assets and playing around with it.
2. Yes it can.
3. Why/What are you trying to do?
@@Veevslav1 I'm trying to know how far i can go with such feature in some older games i play a character can turn himself into a tower as a hiding skill idk but i think this is way different topic
If the character is humanoid then yes the animations will work. However if the proportions are extreme then it might be a bit off.
Sure, you instantiate the SkinnedMeshRenderer/Bones as a prefab and assign the Avatar through code
SkinnedMeshRenderer is a different thing from a Mesh Renderer, you could apply the same Mesh and Material to a MeshRenderer but it would just be static non-animated.
@@GamesAreArt1 For number 3 the character swap out is easy, as Code Monkey said, it would just be a static structure without animations or it would get a new set of animations along with a new skin if it is not humanoid and/or has a different skeletal system...
So if you become a coat rack, you lose movement animation. If you become a cat you lose humanoid animations but could get cat animations. It is all about how much effort you are willing to put in to code something like this and configure it with in the game.
Code is the great thing here. It paves the way to everything else.
Hi Jason this is really cool tutorial! Could you maybe make one, how to have separated invetory on those characters? Because when i swap them they are on one inventory. Iam really struggeling with that. Thank you
This might not work since I haven't tried inventory systems before, but speaking from a programming mind:
if you have your inventory as a separate class, you can just give each character an instance of this class.
means you don't have to give them the inventory code, but rather make a new script for each of them and inside that script create a private member of the inventory class. This way each character will have it's own copy of the inventory and can call it's functions on it's own inventory.
hope this makes any sense, also hope it works for you.
Thanks! This will be very helpful. :)
It's a good overview.. but I'm still lost. Seems like if you're trying to do this with your own custom made character and rig there's a lot more involved. Thanks for getting the general concept across though.
As long as it's a humanoid rig it should be exactly the same. Make sure you set up the rig corectly in Blender and imported your model as humanoid
If I have some procedural animation that need sto reference bones, they would loose reference when I change bones. Is there a way to keep references to the same bones in a humanoid avatar? Like a standard naming system that I can generate for any skeleton
Thank you for the great Video!
Could you please make a Video on how to do character creator and clothes for the character?
That would depend on how you set up your character. Either enabling/disabling game objects if you have the clothes as separate. Or just changing a Material if the clothes are included in the same mesh.
Great tutorial, as always!🇵🇹
THANK U MATE
If I do this with runtime animated models and then call Animator.Rebind, the scale of the imported model is still the same.
Is there any workaround for that
Mine mixamo rigged model doesn't have an avatar though
Wow thankyou!
Thank you!
it keeps unpacking the prefab.. I use the nested prefab.. then all sort of problems.
For some reason, when I click on the avatar of the new model I want to use I don’t get the option to configure it
Great tutorial!
I've been watching your content for a while now and was wondering if you had a tutorial for actually rigging the bones of a character? I've been trying to rig a character in blender for the past couple days but something with exporting it to unity doesn't link correctly. I've posted a few things on reddit on the unity and blender pages but no one seems to have any idea. If you could make a tutorial explaining a correct way to rig in blender or unity I would be eternally grateful.
Unless you already have one then could you point me towards it.
Nope sorry, I'm very much a beginner in Blender and I've never done any Rigging, not sure if there's any specific workflow to Unity, maybe you can import one of these characters into Blender and look how they're setup?
Sebastian Lague has a good video on it here: ua-cam.com/video/jp_SqjB0468/v-deo.html
It's part of a collaboration series he did with brackeys which covered all the RPG essentials, including sculpting your own character in blender
i have a script i do this at runtime with, should that work too?, it doesnt
And if i want to have multiple models to swamp to? Isn't there a way to do it without having to rename the new object every time to the ones referenced in the bones?? So i can organize many models and just toggle them on and off when i need to
For that you should just have different prefabs each with a different character setup
This has been a awesome way to breath life into my prototypes, thanks so much! But I'm experiencing a weird bug. As I've been playing my games there has been a noticeable jump when my camera rotates and it gets worse the longer I play, to the point of jumping 90 degrees in one movement. Any thoughts would be appreciated friends!
Is it really the camera or just your game freezing for a moment?
Camera movement is using deltaTime so if the game freezes for a bit then the camera will "jump" a lot in the next frame. Look in the profiler, maybe you're spending too long on garbage collection
Excellent tutorial as always. Question I have is- is anyone else synty character going thru objects? I'm using the apocalypse assets v1.09.
The assets are just visuals, they are completely separate from physics, so that depends on how you handle your character controller and your world colliders.
@@CodeMonkeyUnity meaning I will have to add to add colliders to the Synty sets right? lol Thank you so much for your reply and help
What if you want to swap characters but select all? So swap primary in otherwords for a style like baldurs gate or Kenshi etc.
Perfect!!!!
I've tried to change for a skin from Mixamo ... but the mesh is showed flying, and I don't find an explaination for this behavior ...
How would you make a skin selection system?
if you will try to script it.. it's won't gonna work at ther runitime
I imported an FBX of a character, but there are no AVATARS to assign. What are those avatars?
On the import settings in Unity you can select "Create Avatar from Mesh"
Hi Code Monkey Could please do a character selection video i.e for one scene to other i am currently stuck doing it for the third person controller cause not able to dynamically change the Avatar any help would be appreciated .
Please Help !!!
How could I make my 3D model with a kind of cutscene? Like a transformation, like super saiyan, without a menu.
Mesh morphing? Look into Blend Shapes
But in most cases things like that are actually just regular mesh changes hidden behind effects
@@CodeMonkeyUnity Thank you
Hi, could you maybe make a tutorial on The GraphTools Foundation Package?
That's interesting, I wasn't aware of that package, seems like the last update was a year ago though.
How could I make the models change automatically? I want to make my character go around changing "frames" at the right times, it's composed of voxels (It's like pixels, but it's 3D).
Would this work with the Synty Mech pack they just released. Specifically the Mechs, not the pilots.
I haven't tried that pack myself yet but assuming they have humanoid rigs yes this should work
For customization I covered that topic in more detail in this video unitycodemonkey.com/video.php?v=nSmEirb8JGM
What about to update old unity3d file to the new version ?
Updating to new versions just means opening the project in the new version. You just can't go backwards
i have a pack that does not have a character avatar, is it still possible to do it? because i tried but and wont work, so i was wondering if there is a workaround
On the Import settings you should be able to have Unity auto-generate the avatar (assuming it's a humanoid mesh)
What i was looking for was how to transform my charcter into a beast form? will i need a beast form mesh and retarget it or is there a way to automate anthromorphic transformations as well?
Sounds like you need to look into Blend Shapes, it's a topic I haven't researched so not too familiar with it.
Has anyone else noticed that sometimes when you import character from mixamo the left foot is twisted?
I have noticed that some characters/animations do have some strange issues with the feet, one solution is to duplicate the animation in order to make it editable and change it, or go into the Avatar and change the range of motion
Do you need to rename all the bones on the new model to have the animations work?
No, the bones are assigned in the Avatar in the mesh import settings, as long as you're using a Humanoid mesh with a Humanoid avatar they will load correctly
Hi Code Monkey! I was changing my character's look, and now when I hit play it animates, but the mesh is really skinny or something, like I can see some dots and lines in the play mode, but the model isnt filled out, do you know why this is?
Sounds like something in either your Animation or your Rig is broken. Try a different animation or a different character
my question is: How do you use this with animation rigging
Not sure what you mean, Animation rigging works on top of a skeletal mesh, regardless of where that mesh came from
@@CodeMonkeyUnity yes you're right. I finally got it to work. My problem was that I had the entire model FBX imported under a player object that had an animator and many other scripts running on it. But after watching your video more carefully, I was able to place the skeleton and mesh renderer directly under the player object, allowing animation rigging to work. Thanks for your response🙏
Thanks for this great video. does this by chance work for changing out characters that are updated to have blendshapes? I have a situation where I have a new FBX with facial blendshapes and I want to swap them into another prefab already using the same model without blendshapes.
I've never used blendshapes but doesn't it use a SkinnedMeshRenderer? If so then everything should work the same
what if i have ragdoll on my bones ? can i do it this way ?
Usually you want either Animator or Ragdoll and not both at the same time. So yes you could have a ragdoll, just make it all disabled/kinematic while the animator is moving it
I have a ragdoll on my skeleton. Should i recreate the whole ragdoll process?
Yes you would need a different ragdoll for different skeletons
@@CodeMonkeyUnity Isn't it possible to only change the skin?
@@fabianobersovszky6987 You can just change the skin if that skin was made for that skeleton. But if you want to use a different skin that requires a different skeleotn then that new skeleton needs a different ragdoll setup
Thanks for the tutorial, just starting to learn the details about the animation system and it can be hard to find a current tutorial for how to do relatively simple tasks at times.
Speaking of, I have a pack of animations and when attempting to use them with a model it *works* but the animations look off because the new character is wearing armor and the arms intersect the body. Is there a simple way to adjust this when importing the animation/model/rig or do you need to edit the animations to fit the thicker model in an external program?
You can go into the Avatar of your mesh and add limits to the bones. That might fix it or it might be easier to fix the animation itself.
is this the mecanim humanoid retargetting system or is this different
Yes the Unity Animation system is called Mecanim
Nice
Thank you so much for this video.
If i may ask..
How did you switch characters inside game mode...?
Regards..
You would do all these steps through code instead of manually in the editor
@@CodeMonkeyUnity
Thank you so much for the answer..
Maybe one day we can see how to create that script 😉.
Regards..p.s
I.m making tpp rpg project where you can play with 2 characters all the time, that's why i.m looking for that script.
i need help, my character is a half trough the floor
i dont ñnow why is this happening
Check where you positioned the collider and the character visual, maybe you just added a collider at chest height
You've probably sorted it now, but that sometimes happens when you get an animation from somewhere, and the animation isn't set to humanoid.
Go to the animation, and set it to humanoid, as you would for a character.
Make sure your character is also set to humanoid, on the "rig" tab.
Hey! How would I go about changing the default animations though? :o
I try to move the armature around (after duplicating the read-only animation) but it just rips off his parts. lol
What default animations? The Unity Starter project animations?
And what you mean by changing? Modifying the animation itself? You can do that either in Blender or inside Unity with some assets unitycodemonkey.com/video.php?v=bZW2IEmwOEg
Can I do like that for Generic (not use Humanoid)?
The character needs to be Humanoid if you want to retarget Humanoid animations
Thank you for this video, I managed to fix the TPose issue I was having. I do have a question regarding the thirdperson asset setup. I have a script that is a do not destroy on load from the previous scene, which is the character creator. My main problem is that when I play the game normally the player movement is 100%, but if I am enabling the players GameObject that has the skinned mesh renderer based on the users selection from the script that get's populated with either player prefs if they exist or from the selection. The Camera bugs out and clips the character when walking backwards, and only backwards. I am not sure how to combat this. The script basically checks which gameobjects should be enabled based on gender, attachements (hats, glasses, etc) which will be used for loading and saving games as well. I use for loops to enable and disable what should be on Awake on the game scene. With doing this, the backwards is well not functioning correctly, when I move the mouse the camera jumps to the correct Follow Distance again. Any thoughts on what I must look at? Or why the enabling of a skinned mesh gameobject could cause this odd bug?
Setting one gameobject on, and altering the code to switch it off and then select the players set option to active seemed to have worked... still on odd bug though.
I just realised what day it is and I'm being wary...
how would you do this with a rigidbody I cant find any info on this lol
Not sure what you mean, the way you control the character has nothing to do with the visual. You can use a Rigidbody or a moving Transform or a Character Controller or anything, the Animator/SkinnedMeshRenderer is completely separate from that.
@@CodeMonkeyUnity I mean for example if you create a script for a rigidbody. Give it movement and clamped mouse so its an fps style and include a mesh so its not a basic capsule. That part is easy. But there isnt really any videos or documentation about animating the mesh on a rigidbody. I made a blend tree and have spent from noon today until 6:20 pm trying everything reading searching youtube and google. Just to try and find a way to have the blend tree play the animations on movement. With a character controller there is a vast amount of information but when its just a rigidbody there is almost nothing have a look for yourself. Would love to see some example vids on that. For now I think I have to give up on the rigidbody and go with a character controller. Wasted two days :(
VICTORY AT LAST! An Important point is unpacking the prefabs.. duh. Had to slow down the video and take screen shots of what you were doing.. so I could enlarge, and see the EXACT files that you duplicated, and the EXACT files you replaced. SO SIMPLE! But remember, we are students.
What do you mean? What part were you doing wrong? Did you duplicate the files like I did in the video? If you do then you don't need to unpack the prefabs since the duplicates will not be part of a prefab
@@CodeMonkeyUnity I had to unpack the prefab on the UNITY model. Plus I was copying the wrong files. I get it now. thanks.
its not working with other characters than your example
What do you mean? What exactly isn't wokring?
How do I handle a downloaded character with an extra "Armature" in the Skeleton hierarchy? I tried renaming either the hips or the Armature names, and I tried moving the Hips up the hierarchy and changed that name.
What do you mean extra armature? It has two skeletons inside it? That's odd, it should only have one
Renaming things usually doesn't work, it needs to be exactly like it was when the mesh was created
@@CodeMonkeyUnity Thanks! I worded that badly, but I have it fixed now. I saw my mistake after watching again.
I had an amature on a character that had a hierarchy like the Unity character (Armature -> Root -> Rest of bones). So I had to fix the name of the Armature ("Armature (1)" to "Armature") and then drag the Root (Hips) to the Root Bone in the Skinned Mesh Renderer. I kept only doing one of those.
How do you do the same for 2d?
Depends on what type of 2D character are you using. 2D Spritesheet animation? Or 2D Skeletal?
@@CodeMonkeyUnity Skeletal. I imported a psd and created the bones and IKs. The first prefab is fine, but when I copied and changed the sprites, I can no longer edit the weights of the structure. Maybe I should just put together another psd? What if I want to add say a different t-shirt for each character in the future. I will have to include more layers which will be the same for each psd, since I the set of shirts will be the same. This would be quite repetitive and I was hoping to avoid it. Any ideas?
Edit: solved in reply
Hey CM,
I'm able to get my custom character to animate fine inside the editor, but as soon as I export a build my character stops animating and stays on frame 0 of idle.
Any idea what could be causing this?
Thanks for all the videos and courses, they're extremely helpful.
Someone helped me solve this on discord. I had an extra animator on my custom character as well as the parent object. Removing the extra one fixed it.
Wouldn't it be simpler to just add the animator to your character and putting that as a child of the object that holds the scripts
Depends on how your object is set up, if you have nothing but the Animator in that game object then yes swapping that would work. But if you have extra scripts in that game object then its easier to swap the contents instead
Hi there ,I have doubt in the scene manager.for example ,I have two scenes ,if I use the code (Scenemanager.LoadScene(Scenemanager.Getactivescene().buildIndex);
//When die the current scene loads
My doubt is that if I die in scene 1 or scene 2,will I reload in that scene.
Like if I was in scene 1 ,it loads in 1,if it is scene 2 ,it loads in 2
Yes it seems like that will reload the current scene, just try it
Ok sorry I didn't see this .thank you so much
What packages do I need to get from
Get what? The assets? There's links in the description for the video where I covered the Starter Assets, Mixamo and link to the Synty City pack
ua-cam.com/video/jXz5b_9z0Bc/v-deo.html
ua-cam.com/video/c4jtyDA7vcs/v-deo.html
Thanks code monkey
this is the issue that made me quit 3D, I'll give it another go
not working :(
How so?
Can we make ai like call of duty in unity
Of course, you can build anything
Is there an UE 5 tutorial would be nice 😢
Bro... switch to unity then you won't have to be missing good tutorials.
How about 2D games?
If your 2D game uses a 3D mesh then its the same way. If it's a sprite without any bones then you just change the sprite
@@CodeMonkeyUnity thank you code monkey
4th
This. Is. So. Not. Useful.
(HAPPY APRIL FOOLS 🤣)
you speak so fast
Really? I normally watch my own videos (and others) at 2x speed
@@abdoulraoufgambo As long as they are in front of the camera they will render. If you make a camera orthographic (2D) it still renders any 3D mesh that is in front of it
@@CodeMonkeyUnity thank you very much
terrible tutorial. Dont confuse people with what not to do in the middle of showing what to do.
What?