Here's a great video on a subject you need to learn about in order to make awesome advanced stuff! This is how my Custom Animation System works which allows me to make games with hundreds of animated units like Battle Royale Tycoon. Stay tuned for the upcoming video on how to make a Heat Map!
@dieweltentdecker58783 жыл бұрын
Does this technique also works with vehicles? Cars, ships, planes....
@CodeMonkeyUnity3 жыл бұрын
@@dieweltentdecker5878 Yes, the mesh doesn't care what object it represents, it's just a bunch of vertices and uv coordinates.
@blueberrygames3213 жыл бұрын
Thank you so much for making these videos. If you ever see this, do you know how well this animation system you created competes with spine? I know spine is paid, but I really enjoy using it- I just want to learn more about the finer details of one versus another. Thanks!
@kaisonduncan71513 жыл бұрын
I dont mean to be offtopic but does anybody know a method to log back into an Instagram account?? I stupidly lost the password. I would love any assistance you can offer me.
@boonesergio26003 жыл бұрын
@Kaison Duncan instablaster =)
@nurlanakylbekov72665 жыл бұрын
I don't remember when I subscribed to this channel. This is my first time watching. I'm definitely sure this channel is going to be my favorite channel. Did not skip no one ads. Thank you
@CodeMonkeyUnity5 жыл бұрын
Glad you like what you see!
@john23774 жыл бұрын
I just need to sincerely thank you for what you are doing.
@CodeMonkeyUnity4 жыл бұрын
Thank you for watching!
@MarekNijaki4 жыл бұрын
This is one of your best videos so far. Finally I think i get grasp of understanding of those UV. Was struggling with them when started my jurney with shader graph. Again - awesom work!
@paulblart73783 жыл бұрын
A bit late, but thanks so much! I’ve been instantiating a bunch of objects with sprite renderers for my grid-based game world and that had some serious performance issues. This is so much faster and easier.
@CodeMonkeyUnity3 жыл бұрын
Yup meshes are awesome for performance!
@Pythontheking5 жыл бұрын
i found this channel through ads and it is awesome
@CodeMonkeyUnity5 жыл бұрын
Glad you like the videos!
@Toopa885 жыл бұрын
I hope your private life is as amazing as your tutorials :)
@CodeMonkeyUnity5 жыл бұрын
Thanks!
@rickloyd82084 жыл бұрын
Thanks, I saw this video a year ago and only now I am ready to use it to improve batching and frame rate :)
@loot64 жыл бұрын
Really professionally made videos.
@CodeMonkeyUnity4 жыл бұрын
Thanks!
@BrainSlugs834 жыл бұрын
You should use sin or cos to move the head up and down; it will look a lot more organic.
@diliupg3 жыл бұрын
What a mesh you made out of those meshes! :-D Good stuff bro!
@yasg59224 жыл бұрын
Thanks! This will definitely help me in my game dev journey. Your videos help me a lot! :)
@CodeMonkeyUnity4 жыл бұрын
Glad to hear it!
@jonathanbarone12574 жыл бұрын
Excellent, very simple and totally explained. Thanks you!
@c0d3d855 жыл бұрын
If you were interested in making a mesh cutter tutorial that would be awesome!
@CodeMonkeyUnity5 жыл бұрын
Oh yeah that would definitely be awesome, need to do some research since I've never actually done it.
@quanghong39225 жыл бұрын
Use triangulate algorithm
@endasil4 жыл бұрын
Spent an hour troubleshooting because I did not have the size on my camera set to 120 and therefor only saw a blue triangle. Since the video just mentioned that there was a simple camera and the background was set to black, i assumed that was all the differences there were.
@zolan42773 жыл бұрын
I would like to applaud you for your dedication to aligning your code. You have true style and very readable code.
@CodeMonkeyUnity3 жыл бұрын
Thanks! I do try hard to always write good clean code
@zolan42773 жыл бұрын
@@CodeMonkeyUnity I hope others learn from you. It is very rare to see such pretty code. Keep awesome!
@OmeedNOuhadi2 жыл бұрын
Thank you so much for sharing this technique with many uses!
@techbytefrontier4 жыл бұрын
im watching , trying to have my own animation system.. need that in my game to facilitate some syncs work. Thanks for that
@MegaMGstudios Жыл бұрын
Hey, this may sound a bit odd, but thank you for having a website with your videos embedded. I used this for a uni project and an actual website sounds way more professional as source than a KZbin video.
@CodeMonkeyUnity Жыл бұрын
That's great! Best of luck with your project!
@MegaMGstudios Жыл бұрын
@@CodeMonkeyUnity thanks, got six more weeks left, most of it will be report writing.
@peanutbutteraddict223 жыл бұрын
like this style of animation. ty
@amca0144 жыл бұрын
Great videos, you spell out clearly from fundamentals what I vaguely but not really understood from hacking about
@erickgclaudino4 жыл бұрын
And that's the way to create minecraft! Facing towards a mesh = showMesh. Otherwise, it is not draw. haha Awesome as aways Code Monkey
@petarstoyanov90245 жыл бұрын
Looking forward to the gridmap!!!
@данет-э5л10 ай бұрын
@CodeMonkeyUnity ♥ You shoved in the start that "sprite renderer" component doing exactly the same " by creating 2 poligons" where it will renders its sprites. So i now wonder - is it posible to create custom mesh to use for Sprite Renderer? im doing 2d game and i need some dynamic shapes but i dont wonna create 3D object and use hard on GPU materials and shaders (i wish to only use sprite renderer if its posible?). So is it posible?
@CodeMonkeyUnity10 ай бұрын
Sprites create their own meshes, I don't think you can specifically change that. But for the GPU a Mesh and a Sprite is the exact same thing, those are just 2 dfferent representations but for the GPU it's all the same, it's all meshes and materials.
@данет-э5л10 ай бұрын
@@CodeMonkeyUnity hmm. much thx
@J-qy7tf Жыл бұрын
Hi Code Monkey! Thank you again for an amazing tutorial! This helped me greatly on an idea I had regarding a different chart type. I did encounter a slight issue though, and this question spans across this video and the bar/line chart videos. When running the program, everything from bar/line graphs showed correctly. I tried to integrate the mesh from this video for an experimental idea. However, the newly generated mesh from this video only shows on the scene view. For the game view, it seemed to only be captured by the camera (generated in world space?) Experimentation: - Tried setting my canvas to either "screen space -overlay" or "Screen Space-Camera" - Tried nesting the "Testing" game object into the "Window_Graph/GraphContainer" object as siblings of DashTemplate and LineTemplate etc. - When the program was running, the camera was slowly adjusted until the newly generated mesh came into view (which is how I found out the mesh was generated in world space) May I seek your advice on this? Thank you in advance! :)
@yousafzahir26722 жыл бұрын
Thanks, this was very helpful!
@asyncoperator3 жыл бұрын
Thank you so much Code Monkey. This is a great starting point what I try to achieve but still facing with some issues and some helps. What I am trying to do is creating a single mesh with 6 verts 6 uvs and 12 tris and then apply two different materials to it. Half of the mesh with one material and other half with another material. Thanks :)
@Kristopher_Logan Жыл бұрын
not sure this is possible within unity. I thin its something that can be done outside the program, but I have never seen a unity generated object with more than 1 material assigned to it
@matama90534 жыл бұрын
Could you also make a video on how to make particle effects from COMPLETE scratch (from the creation of the textures to the full animation) please I am having a hard time finding tutos about this
@vivekpattnayak8443 Жыл бұрын
can someone explain the code of tile mesh, cant seem to get it
@tomershmaya88524 жыл бұрын
Great video, as always! It made me rethink animations, coding it "close to the metal". I tried to delve into the code in the project so I could recreate a very basic system with the same idea and well it's...so very complex (mostly because it's made of so many components). Now, most of your videos (character movement, aim, los, you name it) rely on this custom animation system, and thus are not working well with "classic" sprite-animation (i.e. different body parts are not animated separately), leaving the choice to take the system as is or to downgrade the functionality of the code to fit classic sprite-animation. For instance, sprite-animation might have only a x-scale factor whether it's animated moving left or right (no back side or front side), while your system's move/anim-direction is a Vector3 allowing much more flexibility. I wonder if you can make a (series of?) video explaining how to build a basic version of this animation system, mainly how to handle different body parts simultaneously (yet, located on the same sprite-sheet). Thanks.
@CodeMonkeyUnity4 жыл бұрын
Yup doing more in-depth videos on the animation system is something I want to do, I'm currently researching how to apply it to DOTS which would make it insanely fast.
@tomershmaya88524 жыл бұрын
Glad to hear that!
@EricKesterson4 жыл бұрын
I just discovered these tutorials, and while I'm greatful for them being made and presented, I actually would prefer if each one was able to present the concept on it's own without relying on other things developed in previous tutorials or code in a custom library or util class. I hopped on the tutorial series because I saw that there was an A* parthfinding tutorial and when I started I realized I need to watch the Grid tutorial first, then I wanted to follow the Grid tutorial with generics, but it became clear I should watch the heatmap tutorial first. and in that tutorial it basically declares that watching this Mesh tutorial is a must before doing that one... I'm 4 videos deep and off the path of what I was originally trying to accomplish. I understand why these things often build on each other, but when they do they often suggest there's one way (or one best way) to accomplish many tasks. As much as we can keep these systems decoupled from each other the more we have the flexibility to pick and choose approaches that are appropriate to our needs.
@AmbassadorOfLogic2 жыл бұрын
@@CodeMonkeyUnity hi, when is the promised video?)
@SayedSafwan10 ай бұрын
Really cool!i want to make grid system with it, where i can interact and click the individual quads with my mouse, how can i achieve it?
@juanvq6904 жыл бұрын
Great tutorial! Just a question... A have implemented this "system" in my game and every character is now formed by 1 mesh with 6 quads (hair, head, body, arm and two legs)... Now, how would you make animations for the mesh? Like walking... I guess you have to move the vertices of the leg quads? Im having struggle with that...
@CodeMonkeyUnity4 жыл бұрын
Yup you move the vertices every frame. What I do is save the animation as a list of vertices positions and play that back over time.
@Peter22055 Жыл бұрын
I think i know where is the problem, when you made some code the data of that appeared in mesh filter. When i do it, no data appears it's just empty
@rafaelcorrea79595 жыл бұрын
Hello again! I would like to congratulate you first, because most of the people actually create unique vertices for each triangle, and you actually reuse them. Second, I would like to know how you handle multiple textures on the same mesh. I'm working on something with a similar tile system from minecraft, and I didn't want to use a texture atlas / sprite sheet for that. In the worst case scenario I would like to merge all the textures together inside a single texture (to work as a atlas), but that would ruin multiple shaders (a glossy, specular one, for example).
@etopowertwon5 жыл бұрын
You use submeshes, see Mesh.subMeshCount , Mesh.setTriangles and friends in Renderer. (UE4 calls uses term sections instead of subsection. Both engines have the same idea: mesh is separated into chunks and each chunk has its own single material. I originally thought it was just for grouping purposes - e.g. left arm, right arm)
@CodeMonkeyUnity5 жыл бұрын
Hmm multiple textures is a tricky one, don't think I've ever done that. One way would probably be with a custom shader, you would receive more than one texture and use them as you wish. You can set the uv2, uv3, uv4, etc on the Mesh.
@rafaelcorrea79595 жыл бұрын
@@CodeMonkeyUnity, just an update, I found a native unity function that packs the textures into an atlas, so part of the problem is solved. Texture2D.PackTextures
@mikifufu5 жыл бұрын
Hello! One question: what's the advantage of using meshes rather than sprites and sprite animation system?
@CodeMonkeyUnity5 жыл бұрын
Meshes don't replace Sprites or vice versa, they are two tools that might be better depending on the situation. If you just want to display a Sprite you should use the simple SpriteRenderer, it will automatically create the Quad for you. Meshes allow you more control on the underlying physical shape so you can do things like the Radar Chart. For the animations, one big benefit of making it Mesh based is performance. Using the Sprite Animation System you will have each Sprite using a different game object. So if your character has 10 body parts you will have 10 game objects. Then if you have 1000 characters you have 10000 game objects which will make your game unplayable. Whereas if you make the animation mesh based and simply animated the vertices and uvs you can have 1 game object per each animated unit allowing you much better performance. Always pick the right tool for the job.
@nantohola44274 жыл бұрын
@@CodeMonkeyUnity Then that's the reason when a person make an RPG with lots of monsters they always use the same sprites but with different colors for new enemies?
@RialuCaos4 жыл бұрын
@@nantohola4427 That's more because it's a lot less work to simply swap out colors of existing enemies than to create an entirely new enemy sprite / animations. Another reason is because that practice started with the NES and SNES when the amount of memory you had to work with was very limited, so it was vastly more memory efficient to simply swap color palettes for new enemies instead of taking up more texture space with an entirely new sprite.
@_CloudyBunny4 жыл бұрын
Also you can create soft bodies!
@MarekNijaki4 жыл бұрын
@@CodeMonkeyUnity I watched some of Unty videos about rig based animations, and they seems fast, even on multiple objects (because of multithreading). Does your approach is better compared to rig based animations?
@UnityRonakGamingGaming Жыл бұрын
My player starts at a point, draws a line where it goes, when it comes back to its place, we get a shape. How can we convert that shape into a mesh. The player continues to move.
@etopowertwon5 жыл бұрын
Nice. Reminds me, UE4 uses counter-clockwise order for front faces. I recently tried to do cube in 3D and got so confused by all dimensions and order, that to get the correct order in the end I made text file to shuffle vertices without the need to recompile the project.
@CodeMonkeyUnity5 жыл бұрын
I've never used it for 3D Meshes but yeah I imagine trying to manually set up the triangles for a simple cube would be quite tough. I guess that's why 3D modelling programs can be so expensive, doing all the math to figure out how to correctly connect all vertices.
@IsFutureHere9 ай бұрын
What are the advantages of this approach comparing to just have two sprite renderer for body and head?
@CodeMonkeyUnity9 ай бұрын
With this you have just one Game Object, just one Mesh being rendered. If you split it all into parts, then a character with head, body, 2 hands, 2 feet will be 6 Game Objects and 6 Meshes. It works fine if all you want is a handful of characters, but I purposely designed this system for my game Hyper Knights where I wanted thousands of characters on screen.
@IsFutureHere9 ай бұрын
@@CodeMonkeyUnity thank you for the explanation! Didn't expect such prompt response wow
@Kristopher_Logan Жыл бұрын
I have not watched the video, I was wondering however about something. if I generate a model, keep the vertice counts intact, but when creating triangles, do the usual look up function I do for finding matching vertex indexes, and then, instead of removing vertices, just selecting the first matching index, will the uvs stilll look right after? I tried generating the model, assigning direction ids to vertices and then telling the system to generate uvs after doing smoothing, but i just wound up with misplaced uvs overlapping each other. I was wondering if keepinng all the vertices from the orginal generation, and then doing vertice look up for triangle creation will still preserve my uv coordinates. this is for a UV mapping program I am making for procedural objects
@cornixthethird98604 жыл бұрын
What are the advantages of this system for animations and effects?
@CodeMonkeyUnity4 жыл бұрын
Drawing a thousand quads in a single mesh will be 100x more performant than a thousand separate Game Objects In Battle Royale Tycoon the game can handle ~800 guests at once because each Guest is just one mesh, if each Guest had a separate game object for each limb I wouldn't be able to have a fraction of that.
@cornixthethird98604 жыл бұрын
@@CodeMonkeyUnity Oh that's huge, thank you
@rickloyd82085 жыл бұрын
and why we should not use sprites? What's the advantage of doing everything from code? The downside is obvious, no visual editor :) Thanks
@CodeMonkeyUnity5 жыл бұрын
This isn't meant to be a replacement to the normal SpriteRenderer. If all you want is to display a single sprite then a normal SpriteRenderer will do. However if you want to create a Heat Map or Tile Map then you would need 1000 GameObjects individually with a SpriteRenderer which would make your game run at 1fps. Whereas with a Mesh you can set the vertices and the whole thing runs on a single GameObject. The way that I can manage to have 800 uniquely animated Units at once in Battle Royale Tycoon is because each of them only has One GameObject. If each Body Part was using a different GameObject with a SpriteRenderer then those 800 Units would require around 6000 GameObjects which again would make it unplayable. Another use is for irregular shapes like you can see in the Radar Chart effect and many other effects you can achieve with weird shapes and vertex manipulations.
@rickloyd82085 жыл бұрын
@@CodeMonkeyUnity you are awesome! Thanks for clarification! So basically with mashes you reduce amount of game objects and you have full control over how everything will be rendered... it's kind of creating "sprite source" but in real time =) I missed your previous video but I will check it for sure. Thanks again for great videos!
@diadetediotedio69184 жыл бұрын
@@CodeMonkeyUnity Unity Tilemap System (?)
@benn9458 Жыл бұрын
Are there any other setup steps I might be missing or messing up that prevent my mesh from appearing on the screen? Maybe z-coordinates or lighting or layering or setting the material properly? If I add a MeshFilter and a MeshRenderer as you did in step 1 and then select the default "quad" mesh asset and I can't get anything to show on my screen. Tried changing the scale values of the transform and coordinates. I also tried setting the vertices, uv, and triangles in my script and playing with the material but still can't see anything. Why does your mesh appear as a pink color by default? I didn't see the color being set anywhere is that just a default mesh material color?
@CodeMonkeyUnity Жыл бұрын
Is the object in front of the camera? Maybe you're looking at the backside? Pink means shader error or in this case no-shader.
@Hiedalle Жыл бұрын
Hi, I am trying to distort/warp an image i have in the scene. i have a game object with a rect transform and an image component attached (displayed on a canvas). the gameobject moves with a constant speed from left to right through the scene. i would like to top half of the image to move slower than the bottom half. any idea how this is best implemented? do i need to add a quad mesh?
@CodeMonkeyUnity Жыл бұрын
Yeah for that effect it sounds like the best option is indeed a custom mesh where you move the top vertices slower than the bottom vertices. Alternatively maybe do it as a shader effect? I did something like that in the wind shader, it keeps the bottom fixed while the top waves unitycodemonkey.com/video.php?v=VcUiksxYT88
@Hiedalle Жыл бұрын
@@CodeMonkeyUnity that was quick, thanks. I will have a look at the wind video
@diliupg5 жыл бұрын
Great tutorial!
@piotrszymanski8325 Жыл бұрын
Can you tell how do you handle sprite parts ordering? Since all parts are on single mesh how it should be made?
@CodeMonkeyUnity Жыл бұрын
It's based on the vertices array index. So first add the vertices for the body quad, then the head quad
@marcinszymanek3894 Жыл бұрын
Hello! What is the advantage of using mesh based animation system over using unity Animator for separate GameObjects with SpriteRenderer components? Is it cleaner? Faster?
@CodeMonkeyUnity Жыл бұрын
It's much faster to update just one single mesh instead of multiple game objects, although that is only a factor when you have tons of units In my case I had to build this system for my game Survivor Squad where I wanted hundreds of animated units and it was not performant if all those units were made up of a dozen game objects each unitycodemonkey.com/video.php?v=jHt_5y671BQ
@marcinszymanek3894 Жыл бұрын
@@CodeMonkeyUnity Very cool! I Made a circular FoV using this and your other tutorial and it works great! Thank you for sharing your knowledge!
@Rohit-kl4gl21 күн бұрын
but, how I remove mesh vertices by vertices index?
@CodeMonkeyUnity20 күн бұрын
You create a new mesh with a new vertices array with the new amount. Or just set those vertices on some position like 0,0,0; but that might mess up the triangles
@Rohit-kl4gl19 күн бұрын
@@CodeMonkeyUnity ! Thank you
@SoundsBy80K5 жыл бұрын
Really, thank you for this.
@arpitsrivstva Жыл бұрын
Hey man, can you tell me why do vertices have the coordinates as (0, 100) whereas UV have them as (0, 1) if they overlap each other?
@CodeMonkeyUnity Жыл бұрын
Vertices are in world position, they can be placed anywhere in an infinite world, whereas UVs are normalized, they only go from 0 to 1 which is the position inside the texture
@arpitsrivstva Жыл бұрын
@@CodeMonkeyUnity I am making a clone of Paperio2 game and for that, can you tell me how to triangulate the vertices accordingly if i take vertices of the player's position? ..to make something like that. Or any other way?
@mercantilistic2 жыл бұрын
I had to set my UV differently in order to see the colors correctly uv[0] = new Vector2(0, 0); uv[1] = new Vector2(0, 2); uv[2] = new Vector2(2, 2); Why is the texture bigger than 1?
@CodeMonkeyUnity2 жыл бұрын
UV's are normalized, they don't go past 1. Maybe you set your texture in Repeat mode and you intentionally want it to repeat?
@halventicanice66834 жыл бұрын
How do I call the combined meshes separately?
@pvsmouli7727 Жыл бұрын
I have a question using animator & creating head moving animation is lot more eaasier than using mesh right ?
@CodeMonkeyUnity Жыл бұрын
Yes but then you have two separate game objects. The reason why I made this system was so every single character was just one mesh one game object which is what allowed me to have my game Hyper Knights with thousands of characters
@pvsmouli7727 Жыл бұрын
@@CodeMonkeyUnity got it thanks for the reply :)
@emaker12332 жыл бұрын
Can you make a video about Mesh.CombineMeshes, combine instances and submeshes? I'm working on a project that more of less requires all of this but there's little youtube videos on it. I know its an old video but I wanted to ask on a video that was more fitting.
@CodeMonkeyUnity2 жыл бұрын
I've never used it myself but looks pretty simple to use based on the official example docs.unity3d.com/ScriptReference/Mesh.CombineMeshes.html
@geldstern4 жыл бұрын
Thx for ur videos I appreciate that ! But whats the main advantages for using custom animations with meshes over unity built-in animation ?
@CodeMonkeyUnity4 жыл бұрын
The main advantage is performance. If you use the Unity animator you need a separate game object for each body part. So if each character has 6 body parts then just 100 characters will use up 600 Game Objects which will really take a toll on performance. Whereas here a single character uses a single game object which means it is a lot more performant. I first made this system when I was working on Hyper Knights where it was essential to me to have hundreds of minions
@geldstern4 жыл бұрын
@@CodeMonkeyUnity ok, thats a good argument. I will remember that for my next lemmings project ;-)
@阳凯-x4p Жыл бұрын
Hello!how can I get the spriters?such as the soldiers or knights
@yancur2 жыл бұрын
Really cool explanation! Thank you. One question, what if I wanted put the body in front of the head? I tried to manipulate the z value in the vertices but it doesn't seem to work. Is there some other way of doing it? (other then changing to order they have the head and the body have been created)
@CodeMonkeyUnity2 жыл бұрын
Yeah inside the Mesh the sorting order is based on order in the vertices array. I can't remember the order now but I think it's back to front. So first define the 4 vertices for the body quad, then the 4 vertices for the head and it should be on top. Or maybe it's the order in the triangles array? It's been a while so I'm not 100% sure but it's one of those two.
@yancur2 жыл бұрын
@@CodeMonkeyUnity I actually figured it out. Not sure if it has some caveats, but it seems to work for now. Instead of using material type *Unlit/Texture* i swapped to *Unlit/Transparent Cutout* . Now it does take in account the Z-axis when sorting. Though I am not quite sure how this change affects performance.. Your solution does work, though if I want to flip it back and front many times, not sure if recreating the array each time would be very efficient. Maybe some more sophisticated array index swapping it could be doable fairly cheaply. But I am afraid that is above my paygrade currently :D
@christianriha5273 Жыл бұрын
Thank you very much for this great video. It helped me a lot to understand how vertices in meshes work. One question though: Is it possible to add further vertices to an existing mesh at runtime or to delete existing vertices at runtime?
@CodeMonkeyUnity Жыл бұрын
Sure, you can update the mesh.vertices at any time, as long as you also update the other arrays you can add/remove anything
@quanghong39225 жыл бұрын
Great channel great content
@neozoid7009 Жыл бұрын
is this in 2D or in 3D ? Because in 2D there is no mesh filter and mesh renderer for a sprite or When I put a sprite in the scene. Or is this applicable for both ??
@CodeMonkeyUnity Жыл бұрын
Both, a SpriteRenderer is really just a MeshFilter/MeshRenderer with a Quad mesh, main difference is you need to create a Material to assign the Sprite Texture
@halfalligator65183 жыл бұрын
if i were to mimic 2d water with splashes and waves (side scroller). Are meshes the way to go? Is it good practice to move the vertices around every frame or is there a better method? Maybe that's exactly what they're made for - i wouldn't know as I'm fairly new to Unity.
@CodeMonkeyUnity3 жыл бұрын
Yup that's one way to do it, if you need it to be super performant you can go with a shader
@batfasturd4 жыл бұрын
Great videos, Just wondering why you decided to create your own animation system instead of using Unity's built in animation system?
@CodeMonkeyUnity4 жыл бұрын
I wanted to animate various body parts and have hundreds or thousands of units on screen. Using my animation system each character is just 1 game object and 1 mesh If I used Unitys animation system I would need a game object for each body part so I would end up with 6 Game Objects per Unit which would massively limit how many units I could have at once. If your design does not require massive amounts of units then the default animator works just fine
@batfasturd4 жыл бұрын
Code Monkey , good to know, thank you for taking the time to make the videos and reply.
@TheRamblingRamReviews3 жыл бұрын
@@CodeMonkeyUnity I was curious about this too. Thanks for answering!
@terrapab2 жыл бұрын
Hi! Thank you very much for your content. I know this video has its time, though I have a simple question. Why do you use the FunctionUpdater instead of the method Update of the class? thank you!
@CodeMonkeyUnity2 жыл бұрын
Just because it's an easy way to add some Update code without having to make an Update function or run the code on a MonoBehaviour script. In terms of end result, they are both the same
@JN-qh9fl4 жыл бұрын
How do you calculate the pixel position Lower left and upper right for your body\head? If I create my own texture and want to apply this method to that but it's a completely different size x, y; and I have several different parts then these numbers would be completely different. I've tried to use Unity's sprite editor but I would have to manually categorize each position ahead of time. I don't mind doing this if that is the way it needs to be done but you don't really go over how to properly find those values. Am I overthinking it or did I miss something?
@CodeMonkeyUnity4 жыл бұрын
You can see the pixel position in whatever drawing program you're using. On Photoshop you have the info tab that shows the current mouse pixel position. To get the normalized value for the UV you simply divide that number by the total width or height
@JN-qh9fl4 жыл бұрын
@@CodeMonkeyUnity Thanks for the reply. You actually cover the calculation in your first video about meshes and I had to use both videos to fully understand how to display the different parts correctly. I'm using GIMP and it seems the mouse pos in pix in that program differs from Unity. If my texture is 512x512 and the pos of my body part is 0, 70 in GIMP, it's 0, 470 in Unity.
@DropsmithUSA3 жыл бұрын
for some reason my console is poppping a CS0101 error even tho the code is written the exact same
@AmbassadorOfLogic2 жыл бұрын
how to rotate elements correctly? and how to work with multiple materials?
@CodeMonkeyUnity2 жыл бұрын
You can either rotate the transform which will rotate everything or do some math and rotate the vertices For multiple materials I think you can change the mesh uv2, uv3, etc
@nguyeninhtai52444 жыл бұрын
excuse me, sir. I follow you create mesh shape 2d, It works perfect in editor. But after build into mobile phone. It's not showing. Can you help me solve this problem? Thank you
@CodeMonkeyUnity4 жыл бұрын
Maybe you're using a shader that is not supported in mobile? Check your log files
@данет-э5л9 ай бұрын
@CodeMonkeyUnity Hi again ^_^ 🙂 ♥. Can u please help me to understand why when i just try to "meshFilter.mesh.uv[0] = new Vector2(_value, 0);" directly change values on the mesh it self - it doesnt work. But when i do it on Vector2[] uv , and then apply this uv to our mesh - then it works? why i have to apply whole array to my mesh if i only need to adjast just some specific small one part? its seems like excesive work that would'v been grate if we could avoid it. isnt it?
@данет-э5л9 ай бұрын
and if there is no way to make a change right away on a mesh, what is then would be more expensive? To write "_meshFilter.mesh.uv = _uv;" whole UV to our mesh for every single square/triangle changes? or to have separate gameobjects with its own mesh filters and renderers and update only exact object that we need at a time and not touch others?
@CodeMonkeyUnity9 ай бұрын
Yup you have to update the entire array on the Mesh. That's because the GPU only receives the updated data when you do that. If you just modify the mesh array you are only modifying the copy on the CPU and not the GPU
@данет-э5л9 ай бұрын
@@CodeMonkeyUnity Much thx for answer ♥. What do u think will be smarter/performant approach? if I have to update just one or two triangels from huge mesh, like 1000 of them. is it still better to update whole UV like that? Or better to create separate objects with own meshes with just one - 2 triangles and update just the one which I need?
@planetdilien29325 жыл бұрын
And this comes out a day AFTER I Finaly finished doing one on my own...
@CodeMonkeyUnity5 жыл бұрын
Now expand upon it! Make a Heat Map or a Animation System!
@minicikoyunda36303 жыл бұрын
Thank you.
@essentialasa4 жыл бұрын
I'm thinking this will be useful for prototyping in unity 2d.
@BrandonFerrentino4 жыл бұрын
for some reason my code doesnt add the mesh filter to the inspector
@volodymyrshein71904 жыл бұрын
Great tutorial! Though one thing - is there no z-order issue? Or ... last triangles will be drawn last anyway???
@CodeMonkeyUnity4 жыл бұрын
The rendering order within a mesh is defined by the order of its vertices. The last vertex gets rendered on top of the previous one and so on. So for making a character like I use in my animation system, first put the vertices for the body, then the ones for the head.
@zildeos98583 жыл бұрын
im doing this on a 3d scene (i know i shouldn't)and every thing is right except for the triangle setup *if you're using only 3 you have to have them be invert clockwise like 0=2,1=1,2=0 but if you extend it to 6 the last 3 have to be setup clock wise* again i know i shouldn't but i had to and would like to know why if anyone knows the answer by the way i didn't experiment too much with it but i just tried ways until this one worked.
@CodeMonkeyUnity3 жыл бұрын
The order doesn't change regardless of how many polygons you have, so in your case your last 3 vertices are probably set up differently from the first 3. In 3D you also need to be careful with where the camera is, if you put the camera in one position you need to go clockwise, if you put it in the opposite position you need to go counter clockwise.
@zildeos98583 жыл бұрын
@@CodeMonkeyUnity thanks i actually though the triangles index was dependent on the vertices index the way the camera is set up is i just made it to orthographic and rotate it 90 in the x axis so it's basically 2d except the y axis is now a z so it doesn't give me too much trouble
@user-hz4tc2pf3x5 жыл бұрын
A small series on how to make a tycoon game? (doesn't matter what tycoon idea have, still suitable)
@CodeMonkeyUnity5 жыл бұрын
Yeah that is definitely on my list, need to think of a really simple idea.
@eruchii72004 жыл бұрын
Hi code monkey. Thanks for another great tutorial. If im not mistaken, we are mapping same material to every triangles repeatedly, so it looks like cluster of squares. What if i want to apply material normally like other mesh (i mean 1 material are stretch across the mesh). How can i do this by code?
@CodeMonkeyUnity4 жыл бұрын
You manipulate how the material is displayed with the UVs. Each vertex has a UV that sets the texture coordinates that vertex should display. So to display the whole texture set the lower left vertex to uv 0,0 and the upper right to 1,1
@eruchii72004 жыл бұрын
@@CodeMonkeyUnity ok. Does it means if the mesh shape like a cross or whatever, we still need to calculate and map each triangle uv manually?
@tomershmaya88524 жыл бұрын
@@eruchii7200 UVs are mapped to vertices, not triangles. You don't care about the triangles beneath when you map the UVs. Any texture is rectangular in its base, so I guess when you say it's a cross-shape you mean that around that cross it's transparent. So you still map lower-left vertex to uv00 and upper-right to uv11
@christinadragoeva17933 жыл бұрын
How can I determine stitched and detached polygons?
@CodeMonkeyUnity3 жыл бұрын
I guess you could go through the vertex list and check which indexes are only used once
@mygamingimagination81734 жыл бұрын
ok so my mesh doesn't pop up how do I fix this
@CodeMonkeyUnity4 жыл бұрын
Pause the game and rotate the camera in the editor, maybe you made the mesh facing backwards
@ofgonen47165 жыл бұрын
Why the heck you dont put your games steam link to description ?
@CodeMonkeyUnity5 жыл бұрын
Oh yeah seems I forgot to add links, here it is: store.steampowered.com/app/851930/Battle_Royale_Tycoon/ Thanks!
@dudeguyman26183 жыл бұрын
Is there a way to update the vertices in real-time?
@CodeMonkeyUnity3 жыл бұрын
Yes you just change the mesh.vertices array
@MrJuancho27064 жыл бұрын
Oh wait, so how i dot a material to cast shadows? is the only thing i need sorry :(
@CodeMonkeyUnity4 жыл бұрын
Any mesh automatically casts shadows, create a standard cube and it will cast a shadow
@lukasin62429 ай бұрын
Why would you assign values to vertices, you used 2 values in vector3( I thought you could give 2 values to vector2 and 3 values to vector3 ). Otherwise great tutorial..
@CodeMonkeyUnity9 ай бұрын
What do you mean? Vector2's are automatically converted into Vector3's
@KalponicGames4 жыл бұрын
@Code Monkey Hi, was wondering if you ever got to make more in-depth videos on the animation system? Also while your tutorials are amazing, people don't get them as stand-alone. We have to watch the previous and previous and so on to do things in your approach. I originally started with your turn-based RPG battle and now It's been more than a day that I am browsing and trying to connect ur previous video to link to it. I was wondering is it possible for you to make tutorial series or stand-alone tutorials which get to the point of solving that problem from scratch? Or even a playlist saying which is step 1 then 2 then so on works. That would be really helpful. Really nice job though. Thanks for being an amazing teacher.
@CodeMonkeyUnity4 жыл бұрын
I haven't done more videos on it but just by expanding upon this you should be able to do it. I've wanted to make a complete video on my animation system covering the meshes, textures, animations, saving and loading, etc, but it's very complex so haven't had the time yet. Referencing videos is the only way I can make videos for KZbin, if I repeat myself and build every single system in every single video then the end result is every video is over 3 hours and no one watches them
@KalponicGames4 жыл бұрын
@@CodeMonkeyUnity Makes sense. But if you kindly make a playlist where it shows where to start and end that would be amazing. Then, viewers would have an easier time to learn instead of trying to figure their own which video was before this one. Also, Can you use this system to animate something like this too? Thanks again for such great content. gyazo.com/448a143ba6c35d490131cf92d14329ef
@mazdnd2 жыл бұрын
@@CodeMonkeyUnity Maybe such a complex video as you mention is better suited as a course? Would probably make more economic sense to spend time on it then? Don't think there's much competition in that space either
@watercat12485 жыл бұрын
I have see meny difrend unity code but I haven't seen haw to make shedder with codes
@CodeMonkeyUnity5 жыл бұрын
Whats a shedder?
@watercat12485 жыл бұрын
@@CodeMonkeyUnity yes this is what have in my mind I think if lurn haw to mack shedder it will be better quality my games
@CodeMonkeyUnity5 жыл бұрын
Do you mean a Shader? If so check out the Shader Graph or Kristin's videos kzbin.info/door/CHg9mt6Tu6f-WCF4gf5oyQ
@林夜明-x1t2 жыл бұрын
两年,你有没有考虑过完整的课程,老师
@nathanrussell95125 жыл бұрын
How come you don't use Vertex helper?
@CodeMonkeyUnity5 жыл бұрын
For learning it helps to understand how the underlying data structures work before starting to use helper functions. I wasn't aware of VertexHelper, will look into it, thanks!
@nathanrussell95125 жыл бұрын
@@CodeMonkeyUnity have you done much on creating UI effects (gradients,glows ect) once you have built a mesh as I would be really interested in seeing some content along those lines if you have.
@CodeMonkeyUnity5 жыл бұрын
@@nathanrussell9512 I've done a bunch of effects that use meshes like the recent Heatmap. On the UI you can also render a Mesh, check out the Radar Chart video
@rifqirizairfansyah2003 жыл бұрын
sorry i cant get mesh utils here
@DropsmithUSA3 жыл бұрын
i don't even know why but i'll follow your tutorials and then for some reason there's always some little line of code or some sort of hotkey that you hit or value that you'll change and then it derails the entire thing im not sure if its just me or what like i know you know what you're doing but i can't seem to follow any of your videos successfully whatsoever lol
@CodeMonkeyUnity3 жыл бұрын
What error are you having? If you specify I might be able to help
@zfhung4731 Жыл бұрын
how to Create 3D Model?
@CodeMonkeyUnity Жыл бұрын
by using any 3D Modelling program like Blender unitycodemonkey.com/video.php?v=95pEfMyhScc
@KaanGuler-df1im Жыл бұрын
in your CreateAnimationMesh // Render Body float bodySize = 70f; Vector3 bodyPosition = new Vector3(0, -50); " How can you define that ı couldn't understand . " vertices[0] = bodyPosition + new Vector3( 0, 0); vertices[1] = bodyPosition + new Vector3( 0, bodySize); vertices[2] = bodyPosition + new Vector3(bodySize, bodySize); vertices[3] = bodyPosition + new Vector3(bodySize, 0); Vector2 bodyPixelsLowerLeft = new Vector2(0, 256); " And also these two lower and upper variables ." Did you find in the sprite editor or somewhere else. Vector2 bodyPixelsUpperRight = new Vector2(128, 384);
@CodeMonkeyUnity Жыл бұрын
The bodyPosition is a world position, it can be whatever you want based on where you want to place it The pixels position depends on how you draw your sprite, what resolution and how you place each body part
@nikolakosanovic99312 жыл бұрын
Can you see mesh out of game view
@CodeMonkeyUnity2 жыл бұрын
The mesh only exists when the code runs so for that you'd have to convert the script into an Editor script so that it runs while not in play mode unitycodemonkey.com/video.php?v=bMuTsAma4tk
@nikolakosanovic99312 жыл бұрын
@@CodeMonkeyUnity thanks
@louischvs93953 жыл бұрын
How not to use a picture but a full color?
@CodeMonkeyUnity3 жыл бұрын
You can dynamically create a 1x1 texture and use SetPixel to set the color kzbin.info/www/bejne/n6Wlg3SBfcuirdk
@Peter22055 Жыл бұрын
It doesnt work for me, no mesh will render for me
@CodeMonkeyUnity Жыл бұрын
Pause the game, select the object, look in the mesh filter and double click on the Mesh, does it have Vertices? Look in the scene view, set it to show the polygons, do you see them? Maybe you're just looking at the behind of the mesh
@Peter22055 Жыл бұрын
@@CodeMonkeyUnity well no, i never see anny mesh, only the preselected ones like square ect
@Peter22055 Жыл бұрын
@@CodeMonkeyUnity I can select premade shapes and they will all show, when i try to use code, nothing happends, it might be caoused by different version of unity? I currently use: 2021.3.8f1
@mohamedshaban26483 жыл бұрын
weird just opened this video to find the ad is another video in the channel
@kambaalayashwanth1233 жыл бұрын
In next video , you will learn how to create unity from scratch
@dasmaffin16335 жыл бұрын
So if you take this up a notch or 203584 notches you could make a modelling software out of this right? xD
@CodeMonkeyUnity5 жыл бұрын
Exactly, that's pretty much how ProBuilder works and you can build just about anything with it right inside Unity.
@dasmaffin16335 жыл бұрын
@@CodeMonkeyUnity could I use this to make a dynamic tilemap? What I need is to change the sprite if the tilemap dynamically, I currently havent found a way to do it with the tilemap itself, or can you recommend something else? This at least gave me a basic idea how I could do that :|
@CodeMonkeyUnity5 жыл бұрын
@@dasmaffin1633 Sure this is perfect for tilemaps. You just need the Texture atlas to contain all the Tiles you want to show and then through code you calculate the UV to get a specific tile to show up in a specific quad. I'm working on several videos covering how to make a Grid Map and Heat Map so stay tuned!
@narf03394 жыл бұрын
What UV mean ?
@CodeMonkeyUnity4 жыл бұрын
It jut means texture coordinates, U is usually the X axis and V is the Y axis
@narf03394 жыл бұрын
@@CodeMonkeyUnity I mean what U and what V mean ? like ultra violet, unknown vertices, undo vertex, unicorn venom ????
@jamado90674 жыл бұрын
You really need to explain the code more, people come to a toturial because they don't know how to do the thing, now you explain the code like they know. Like really plesse
@CodeMonkeyUnity4 жыл бұрын
What part couldn't you understand?
@diadetediotedio69184 жыл бұрын
This seems to have a heavy performance consumption