Coming from a fellow Unityer(?), good job with explaining this, now when people ask me for "how to code mesh deform pls", I can send them this... Yes, I'm bad at explaining... Deserve way more than 247 subs bro, I just gave you one extra!
@CodingWithRus3 жыл бұрын
Thank you, I appreciate the kind words!
@isaacs12173 жыл бұрын
@@CodingWithRus Anytime!
@larsmaas072 жыл бұрын
I am working on a sand castle city builder project and this video definitely helped me. Thanks :D
@CodingWithRus2 жыл бұрын
Glad it helped!
@larsmaas072 жыл бұрын
I am using marching cubes now because the system you use loses polygon resolution/typology when deformed :)
@CodingWithRus2 жыл бұрын
That's good, marching cubes is the correct implementation for what you're creating! Good luck with your project :)
@iliketowatchducks Жыл бұрын
Thanks for making this video so simple and straightforward.
@CodingWithRus Жыл бұрын
Glad you enjoyed! Thanks for the comment :)
@iliketowatchducks Жыл бұрын
Yes! I'm trying to make a sort of isometric 3D terrain if you can imagine that, maybe like throw in some low Polly astethic vibes, maybe like that 45 degree orthographic view type situation. A classic imo. And I wanted to try have a way of deforming the hills or whatever is there, untill it can only reach the base maybe. So still trying to figure out how to make the map etc, getting there , but this video's going to help me get started on the deforming for sure. Super helpful.
@CodingWithRus Жыл бұрын
Sounds awesome! Good luck!
@freshplay29 ай бұрын
meennn..You are a prophet of help.thanks.saved me alot of effort..thanks you.
@josimar84974 жыл бұрын
you explaned so well, thanks and keep it up with the videos!
@CodingWithRus4 жыл бұрын
Thank you!
@RajkumarDarbar3 жыл бұрын
Too good content !! Thanks a lot for making it! Much appreciated !!
@CodingWithRus3 жыл бұрын
Glad you enoyed! Thank you for the comment.
@aichayasmine21684 жыл бұрын
Congrats on 100 subs! Keep the videos coming 😍🎉
@CodingWithRus3 жыл бұрын
Thank you! Will do!
@kaidastudios3 жыл бұрын
Please keep making more. Amazing information! Thank you!
@CodingWithRus3 жыл бұрын
Thank you!
@dertobbe1176 Жыл бұрын
This is great!
@calendulaprox2155 Жыл бұрын
Thank you for this! its very useful :)
@neoteraflare2 жыл бұрын
Watching this in 2022. You are now over a thousand subs!
@CodingWithRus2 жыл бұрын
Big achievement for me! Thanks for commenting :)
@barrykelly74372 жыл бұрын
Great video thanks!
@CodingWithRus2 жыл бұрын
My pleasure, thank you :)
@PiterTraceurFA2 жыл бұрын
Awesome vid man, helped me a ton even though I'm working in UE4
@CodingWithRus2 жыл бұрын
Glad I could help
@alirezaielal82933 жыл бұрын
thank you so much for this great video . keep going body . you explained it very wellll !!
@CodingWithRus3 жыл бұрын
Thank you! Will do!
@unmxtiviert3 жыл бұрын
Im the 510 subcriber Congrats!!!!!!
@CodingWithRus3 жыл бұрын
Thanks David!!
@JHE_Box3 жыл бұрын
Great video, super clear explanations 😊. From one tiny channel to another, keep it up!
@CodingWithRus3 жыл бұрын
Thank you!
@k1ng4012 жыл бұрын
You never did the 7.5? This was a very easy to understand tutorial. Be interested to know how I can detect where I’m touching the mesh with a game object rather than the mouse. Also how to do it with a copy of the Vertices rather than a Reference (if that is indeed quicker).
@CodingWithRus2 жыл бұрын
I know :(, will be coming soon. I have it all planned out just need to film, edit upload. You can use the mech collider component to find the point where the game object hit (you can use bullets colliding with the mesh to deform)
@falf_8711 ай бұрын
Hi, This tutorial has been great! How do I get this to work in 3D, either with a cube, capsule or custom mesh? I was also wondering how you would change the shape of the mesh based on collision with another object, not with the mouse? Any help would be great. Thanks
@gutzimmumdo4910 Жыл бұрын
is there a way to make terraces or sharp walls like straight walls insted of shagged ones? very nice list btw good work.
@joshuasmith756 Жыл бұрын
This is a great video and it's really helpful. Although I'm having trouble while trying to translate this to a sphere. I'm getting a NullReferenceException on line 30, which would be "mesh.RecalculateNormals();" in my code. Is there a quick fix to this?
@אורימימון-ע3ה Жыл бұрын
hey ty for the vidoes! i want to ask how to make Procedural Generation just for a monsters
@ahxel85543 жыл бұрын
thank you!
@CodingWithRus3 жыл бұрын
You're welcome!
@shabadava622 жыл бұрын
Hi Rus! First of all: awesome video, you make me understand a subject that i was trying to learn for a damn while. Tysm Now, I have some issues to implement the controller to another context: So, i want to make the deformation acording to the position of a character controller on the scene, that's not the greatest problem right now, but the fact that i want to add a curve to the deformation in order to make it more smoothly (according to the position of this character controller). I never managed curves for this kind of things before, but it seems as a nice option. Any suggestions?
@CodingWithRus2 жыл бұрын
Glad you liked it! For your case it'll be lots of maths unfortunately BUT a not so optimized way would be to use a "invisible" 3D sphere attached to the character controller and then deform the terrain to the shape of the sphere. Hope that helps!
@joewilliams82863 жыл бұрын
Great channel mate, akin to Code Monkey / Sebastian Lague when it comes to the quality of the information you provide! Got yourself a new subscriber, can't wait to see what you release next
@CodingWithRus3 жыл бұрын
Thanks very much! Really appreciate the kind words
@kuzmychmaksym384310 ай бұрын
2.2K subscribers are watching this now, bro)
@last_thylacine Жыл бұрын
Why do we add 1 to sqrMagnitude in the force formula?
@Famosy13 жыл бұрын
Did you have discord pls?
@CodingWithRus3 жыл бұрын
Hi, not yet but will be creating one soon!
@erikhokis62922 жыл бұрын
Thank you for great video, anyone know why this working only on plane mesh with xz scale 1?when i import mesh or scale plane it not working.
@torstone10093 жыл бұрын
Is it possible to use this but instead of just deforming you could remove parts of the mesh? I want to make a snow system where you can roll a snowball in the snow, the snow will disappear and the snowball will grow
@CodingWithRus3 жыл бұрын
Hi, I really wouldn't recommend removing parts of the mesh if you're not certain what impact this would have. Instead deform it (like in the video) to lower the vertex's. Bare in mind I've never tried to create a snow type system. Thanks and hope that helps!
@torstone10093 жыл бұрын
@@CodingWithRus Yep, deforming was the right way to go! Thanks a lot
@k1ng4012 жыл бұрын
When I attach this script to my procedurally generated mesh I get a “Object Reference not set to an instance of the Object” in the RecalculateMesh() step at the end of Update
@CodingWithRus2 жыл бұрын
Hey, do you have a mesh collider attached to the game object?
@k1ng4012 жыл бұрын
@@CodingWithRus I'm not sure what the original problem was but I worked out how to do the OnCollisionEnter in order to have a colliding object deform the mesh and that works great with a Primitive but not with my Generated Mesh. I had to move the GetComponent step into an OnBecameVisible since my mesh does not actually exist when Start is called. And that seems to work ok. modifiedVerts are being updated with a down component when something falls on them. BUT the RecalculateMesh step although it's being called ok, doesn't do anything when it's my Calculated Mesh. The mesh doesn't change shape like it does when the script is attached a primitive plane. Something about the nature of my Generated Mesh but it seems to have all the correct attributes. It has a Filter, I can get the mesh.vertices.length
@CodingWithRus2 жыл бұрын
Hey, I suspect it will be your mesh collider, double check that it's attached and there is a call on the start method for it. Think that will fix your issue
@k1ng4012 жыл бұрын
@@CodingWithRus I worked it out. My Generated Mesh DOES change shape, just not visually where the colliding object is hitting it. It seems to be deforming the mesh's local coordinates in line with the collision's global coordinate (for example my ball is hitting the mesh at Global coordinate 0,0,0 and the mesh is deforming at vertex 0,0,0 but because I have dragged my mesh to position it so that the centre of the plane is under the ball, that 0,0,0 vertex is at global coordinate -10,0,-7. Do I need to position my Generated Mesh Game Object at 0,0,0 and reposition the ball, camera etc so that they are in the middle? Or is there a way I can translate the collision coordinate to be relative to the Mesh's position?
@HerenowMOBUDUON2 жыл бұрын
hello, I would like to make a restriction on the height and depth of the mesh change, what code should I insert?
@CodingWithRus2 жыл бұрын
Hi, you need to look at using mathf.clamp for the changeable values. Here's the link, it should give you the run down of how to imement it. docs.unity3d.com/ScriptReference/Mathf.Clamp.html
@HerenowMOBUDUON2 жыл бұрын
@@CodingWithRus thx man!
@CodingWithRus2 жыл бұрын
Anytime :)
@mrsingh25953 жыл бұрын
Bro when are the next videos coming
@CodingWithRus3 жыл бұрын
Episode 8 out now!
@pennd4411 ай бұрын
For some reason, the mesh only deforms for me when the camera is at x:0, y: anything, z:0. Does anyone know why?
@aus6022 жыл бұрын
Hellooo im sorryyy but how do i solve this Object reference not set to an instance of an object MeshController.RecalculateMesh()
@CodingWithRus2 жыл бұрын
Hey! You're missing a reference to the mesh controller! If on the same gameobject user GetComponent if on a different object you can use FindObjectOfType
@aus6022 жыл бұрын
May i email you my code and screenshot as im still using same gameobject and find errors only.. could you help me 🥺 Im SO Sorryy.. Im just a school student doing this for my project
@CodingWithRus2 жыл бұрын
Hey, best thing to do is to join the discord and then post your code in the #code-help channel. And then I can take a look :)
@cancandan43272 жыл бұрын
Great!
@CodingWithRus2 жыл бұрын
Thank you
@Pilzefresser3 жыл бұрын
how do I need to change the code if I want to do it with a wall?
@CodingWithRus3 жыл бұрын
You'll just have to flip the axis, so instead of using the z axis, you use the y axis. Thanks,
@Pilzefresser3 жыл бұрын
@@CodingWithRus where do I set the axis? I rotated the plane. But it only deforms the plane/wall when I click on the ground instead of the wall. How do I need to change the raycast code?
@nanifiqueyt2 жыл бұрын
@@Pilzefresser not 100% sure but I think you could just replace Vector3.up / Vector3.down to Vector3.right / Vector3.left
@RamjiR-u4c Жыл бұрын
not at all working.. I followed the same procedure nothing works for me. The variable verticies you are setting is never used in the script.
@CodingWithRus Жыл бұрын
Hi, the source code is attached in the description. Could you give that a go please. I've rechecked the code and it's working. Thanks!
@TheSateef4 жыл бұрын
modifiedVerts should be a copy of the mesh, not a reference. do a new Vector3[length] and copy every cell. the way you are doing it now modifies the mesh points directly and is very slow. see catlikecoding.com/unity/tutorials/mesh-deformation/
@CodingWithRus3 жыл бұрын
Yes! You're absolutely right, it completely slipped my mind when recording this. When you do it the way that I have done it on the code, you're pointing to a reference of that array rather than having a variable create a new array in memory.