To be able to explain such a complex concept in less than 7 minutes is a great gift. Be sure to remeber that, son!! ;) Great work! 👍 Those missing Likes and Subs will come in due course...
idk why but my car just don't seemed to deform, it made in 3dsmax, also since my car has more than one part, when i play in unity with mesh collider and ridgidbody the model just fall apart
This is because you need to add deform, convex mesh collider, and a rigidbody to every object you want to deform. Also check the rigidbody isKinematic to true.
Good question. Read/write has to be enabled because we have to read every vertex in the mesh, store it, and make a new mesh instance that is deformed. Since I'm using filter.mesh rather than filter.sharedMesh, it creates a new mesh instance for each individual object instead of changing the file. Here's a little snippet from the unity docs: "When you enable (read/write), Unity uploads the Mesh data to GPU-addressable memory, but also keeps it in CPU-addressable memory. This means that Unity can access the Mesh data at run time, and you can access it from your scripts. For example, you might want to do this if you’re generating a Mesh procedurally, *or if you want to copy some data from a Mesh.*"
@@polysyncproductions6199 i managed to make one based on your code and another guy, also added an array of meshfilters for body parts like doors, bumpers it works great on mobile on a 10k geometry.
You are so underrated! U deserve way way way more subs! And I'm not just saying that I just subbed right now! I can't believe I didn't find this channel earlier!!!
Thank you so much! You have no idea how much that means to me. I'm currently on a trip, but when I get back I have a couple more tutorials I want to get done, so stay tuned! :)
For some reason, this is not working entirely, the collider mesh get properly deformed, but the visual (the mesh filter) doesn't change at all ! Any reason to that ? Read/Write is enable btw, the mesh filter is also properly assigned. Edit: Oh okay fixed it, this is because I have multiples mesh filter on my car, and the script was actually using the wrong one !
When i collide with a wall or the car the mesh moves but the world space position of the object is the same like it's never moved? it seems like the entire models verts are being shifted
great tutorial btw. loved it. i was trying to raycast from camera to target mesh and find the vertices that got hit from triangle index which i could deform only those 3 vertices and looked very sharp. i did that because i thought looping through all the vertices would be slow. but trying your code, it wasn't. :D and its better. looks nice, works nice. great.
I would need to see your code, but just remember to make sure that you are setting the filter mesh's vertices instead of the mesh file itself. Ps. I'm glad you liked the tutorial :)
That should work. The easiest way would probably be to just set the mesh instead of the vertices. So: filter.mesh = defaultMesh; where defaultMesh is a public variable of whatever mesh you are using.
This tutorial is amazing! Thank you! I think models should be in a modular fashion if you wanna make a deformation based game to keep number of searched vertices minimum.
This is a really good video and I like the car damage a lot! It would be cool if you would make a dynamic car damage tutorial but I can uderstand it is hard to make it.
I'm glad you liked the video! Are you talking about a more in-depth tutorial on making extensive car damage such as breaking windows and doors that fall off? That would definitely make a good addition, I'll have to think about it. :)
Real nice video. I realize post is 2 years ago -- Just getting started with Unity and C# so your code it quite helpful. One thing I noticed is your calc. of pointPosition on line 52 could be moved up a few lines outside of mesh vertex loop so it is done only once and not for every vertex since it is "loop invariant", not sure if the c# compiler would be smart enough to figure that out. Also, wondering if allocation of deform Vector3 should be done once outside all loops?? Again, maybe c# compiler would recognize what was going on with allocation request followed by one reference...
Thanks for the pointers, my code definitely wasn't perfect but it got the job done haha. Hindsight, doing it on the GPU with a compute shader would be much more efficient.
Yes, it will work, but you need to make sure the models are very simple or it will lag. I would remove the line of code that changes the mesh collider because that causes the most lag. :)
very interesting, have you tried adding bends to the damage? Like in Driver, when you collide, the hoods middle part pops up a bit. I guess it's just some so sort of average between the collision and the center of mass, causing some sort of a movement??? Not sure.. what do you think?
Interesting idea. If you split the car into many different parts (example one part for the hood,) you could make a blend tree that would blend from 0 = no damage, to 1 = fully bent hood. Depending on how hard the collision is for each part you can interpolate between normal and damaged hood, instead of going through the trouble of making very complicated cripple physics. That's how I would implement that.
@@polysyncproductions6199 hmm, interesting idea, haven't thought this way before. Here, you can try out my generic physics for the next video, trying out that? :) www.dropbox.com/s/1gnh2ddf33ousr6/pro3dmodels_GVP05.unitypackage?dl=0
It's because TH-cam in their infinite wisdom decided to start showing ads on all videos, but you need to be monetized in order to get money from those ads
Timestamps:
0:00 Intro
0:57 Scene & mesh setup
2:27 The code 😱
4:50 Parameters
5:22 Testing
6:20 Outro
you don't understand how amazing you are
Me too
To be able to explain such a complex concept in less than 7 minutes is a great gift. Be sure to remeber that, son!! ;) Great work! 👍
Those missing Likes and Subs will come in due course...
idk why but my car just don't seemed to deform, it made in 3dsmax, also since my car has more than one part, when i play in unity with mesh collider and ridgidbody the model just fall apart
This is because you need to add deform, convex mesh collider, and a rigidbody to every object you want to deform. Also check the rigidbody isKinematic to true.
This is one of my favorite TH-cam channels. He knows the stuff and spills knowledge. You should do more tutorials
Between I’ve added you on discord. It will be an honor if you will oblige to mentor me even if I have to pay.
wait enable read/write will apply the deformation to the original file?
Good question. Read/write has to be enabled because we have to read every vertex in the mesh, store it, and make a new mesh instance that is deformed. Since I'm using filter.mesh rather than filter.sharedMesh, it creates a new mesh instance for each individual object instead of changing the file.
Here's a little snippet from the unity docs:
"When you enable (read/write), Unity uploads the Mesh data to GPU-addressable memory, but also keeps it in CPU-addressable memory. This means that Unity can access the Mesh data at run time, and you can access it from your scripts. For example, you might want to do this if you’re generating a Mesh procedurally, *or if you want to copy some data from a Mesh.*"
@@polysyncproductions6199 Oh thanks for the details, i looked up the docs and started from scratch.
@@MohammadAlizade Good luck with it!
@@polysyncproductions6199 i managed to make one based on your code and another guy, also added an array of meshfilters for body parts like doors, bumpers it works great on mobile on a 10k geometry.
Sounds awesome!
very underrated
You are so underrated! U deserve way way way more subs! And I'm not just saying that I just subbed right now! I can't believe I didn't find this channel earlier!!!
Thank you so much! You have no idea how much that means to me. I'm currently on a trip, but when I get back I have a couple more tutorials I want to get done, so stay tuned! :)
@@polysyncproductions6199 k :)
@@polysyncproductions6199 do you have a discord server that we can join and chat?
(By we I mean all your fans)
@@thespontaneoustomato2676 I do, its still WIP but you are welcome to join. discord.gg/KGmEc3U
Something you can add to it is get the hit normal of the collision, so that the deformation happens in the direction of the hit.
True! Good idea
My bro 🔥🔥🔥🔥🔥🔥🔥🔥
Can we make it like also bend from the rear end of the wall?
So that it makes.more sense.
Thanks
This is amazing! Thank you for making this! U are amazing!
My pleasure!
THAT'S A LOT OF DAMAGE! LOL! Great job bro. This was really informative and it really helps. Thanks!
Glad you liked it!
hi! How can I fix this problem? The collider is fixed in the positon but the mesh is moving back (sry for bad eng :D)
Disable convex mesh and enable isKinematic on the rigidbody.
@@polysyncproductions6199 Same :/
@@Hurkaaa Are the rigidbody and collider together? Not separate objects?
@@polysyncproductions6199 Yes the rigidbody and the collider is together.
I am the 100th subscriber yay!
Ayyy let's go! 100 sub special?
Cool job man!
For some reason, this is not working entirely, the collider mesh get properly deformed, but the visual (the mesh filter) doesn't change at all ! Any reason to that ?
Read/Write is enable btw, the mesh filter is also properly assigned.
Edit: Oh okay fixed it, this is because I have multiples mesh filter on my car, and the script was actually using the wrong one !
woooowww soo gooodddd
When i collide with a wall or the car the mesh moves but the world space position of the object is the same like it's never moved? it seems like the entire models verts are being shifted
Try setting the deform radius smaller
PolySync Productions ahhh yes the number needed to be super lower than expected, thanks for the assist :)
Glad I could help!
great tutorial btw. loved it.
i was trying to raycast from camera to target mesh and find the vertices that got hit from triangle index
which i could deform only those 3 vertices and looked very sharp.
i did that because i thought looping through all the vertices would be slow. but trying your code, it wasn't. :D and its better. looks nice, works nice. great.
That's a great idea. Raycasts are fun to play around with.
Glad you liked the tutorial. :)
Really great tutorial.
I thought resetting the mesh would be as simple as setting it back to the old verts. Any idea why this isn't working?
I would need to see your code, but just remember to make sure that you are setting the filter mesh's vertices instead of the mesh file itself.
Ps. I'm glad you liked the tutorial :)
@@polysyncproductions6199 Yeah it turns out you're actually changing the default mesh if you don't clone it first. Got it working now! Thanks again
@@BrianBakerCA Happy I could help! Good luck on your project. :)
PolySync Productions if i i call a void say something like "ResetMesh()", would i just set filter.mesh.vertices = originalVerticies; ?
That should work. The easiest way would probably be to just set the mesh instead of the vertices. So:
filter.mesh = defaultMesh; where defaultMesh is a public variable of whatever mesh you are using.
Great video you earned a sub from me, hope to see more videos in the near distance future.
Appreciate it! And yes, I do have more videos planned.
Thanks man
can i get the script boys the description link isn't working
Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5.
i get a error
Select the object that you put the script on, and turn on isConvex on the mesh collider component
I think that the collider didn't change even after changing the mesh so is there a solution for that and thanks for the tutorial
This tutorial is amazing! Thank you! I think models should be in a modular fashion if you wanna make a deformation based game to keep number of searched vertices minimum.
Glad it was useful! And yes, I would recommend splitting up models into different parts to keep it easy on the system.
Very useful tutorial!
This is a really good video and I like the car damage a lot! It would be cool if you would make a dynamic car damage tutorial but I can uderstand it is hard to make it.
I'm glad you liked the video!
Are you talking about a more in-depth tutorial on making extensive car damage such as breaking windows and doors that fall off? That would definitely make a good addition, I'll have to think about it. :)
PolySync Productions breaking glass and falling doors. Than you have a really good car damage system
Do you have a updated discord link?
Yes, here it is: discord.gg/cXPDqbKGSC
Thank you man
Hey great video! Hope your channel takes off. Does this perform okay on mobile platforms?
Hey thanks man! The script is pretty CPU intensive since I didn't optimize it for GPU, but it should be okay for a limited number of low poly models.
Real nice video. I realize post is 2 years ago -- Just getting started with Unity and C# so your code it quite helpful. One thing I noticed is your calc. of pointPosition on line 52 could be moved up a few lines outside of mesh vertex loop so it is done only once and not for every vertex since it is "loop invariant", not sure if the c# compiler would be smart enough to figure that out. Also, wondering if allocation of deform Vector3 should be done once outside all loops?? Again, maybe c# compiler would recognize what was going on with allocation request followed by one reference...
Thanks for the pointers, my code definitely wasn't perfect but it got the job done haha. Hindsight, doing it on the GPU with a compute shader would be much more efficient.
links are not working
how to make Mesh Deformation like this super smooth (@ )
Coroutines?
Great job ! but Script link is not working. Can you reupload real quick?
Thanks!
Does this link work for you?
pastebin.com/GZniJb4H
@@polysyncproductions6199 no
@@juniordeveloper7989 docs.google.com/document/d/1XIcXxaqd8gTMear454FsZOgrVUcHm-_O-CEfESu_k80/edit?usp=sharing
I think the script links are broken, can you share a new link?
pastebin.com/07g6NvzA
will it work for android
Yes, it will work, but you need to make sure the models are very simple or it will lag. I would remove the line of code that changes the mesh collider because that causes the most lag. :)
Thank you
can't find the code
docs.google.com/document/d/1XIcXxaqd8gTMear454FsZOgrVUcHm-_O-CEfESu_k80/edit?usp=sharing
very interesting, have you tried adding bends to the damage? Like in Driver, when you collide, the hoods middle part pops up a bit. I guess it's just some so sort of average between the collision and the center of mass, causing some sort of a movement??? Not sure.. what do you think?
Interesting idea. If you split the car into many different parts (example one part for the hood,) you could make a blend tree that would blend from 0 = no damage, to 1 = fully bent hood. Depending on how hard the collision is for each part you can interpolate between normal and damaged hood, instead of going through the trouble of making very complicated cripple physics. That's how I would implement that.
@@polysyncproductions6199 hmm, interesting idea, haven't thought this way before. Here, you can try out my generic physics for the next video, trying out that? :) www.dropbox.com/s/1gnh2ddf33ousr6/pro3dmodels_GVP05.unitypackage?dl=0
Bro, you have a 106 subs but your video is showing ads
It's because TH-cam in their infinite wisdom decided to start showing ads on all videos, but you need to be monetized in order to get money from those ads
Why did you stop uploading? Btw you look like Christina Hendricks
mesh deform
we want training videos
please make arbic translate your videos are very nice