Search Unity

[NOW WITH SOURCE] Mesh deformation on impact

Discussion in 'Made With Unity' started by Ethan, May 28, 2010.

  1. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
  2. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    I crashed at high speeds and didn't notice any changes :confused:

    Tried ramming my front and back into the walls
     
  3. SirLancelot

    SirLancelot

    Joined:
    Dec 30, 2009
    Posts:
    144
    I didn't see any changes, too... :eek:
     
  4. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    After a few (really just a few) crashes i get this result:




    Perhaps i will post a more sensitive version tomorrow if noone gets this car crashed.
     
    fury9999 likes this.
  5. KatanaSim

    KatanaSim

    Joined:
    Oct 25, 2009
    Posts:
    105
    After hitting the walls a few times there definitely are changes, but they should be much more pronounced. When I use a ramp and crash upside down into a wall, I expect the car to not get out of that alive. :)

    Am curious as to how far you can push this deformation. It's a good start and would probably interest the people who are involved here
     
  6. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    I agree, you should definitely increase the damage rate.
    At 170 mp/h a car should be squished to half when hitting a wall straight :D
     
  7. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    UPDATE:
    - now it breaks more fast
    - bugfixes (Quaternions are hell ;) )
    - now it rocks

    please try it out :D
     
  8. liverolA

    liverolA

    Joined:
    Feb 10, 2009
    Posts:
    347
    any plan for sharing the project??
     
  9. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    I thought about selling it for a few bucks when it's polished.

    (need to earn my Unity 3.0 update ;) )
     
  10. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Definitely notice the crumple in the updated version 8)
     
  11. KatanaSim

    KatanaSim

    Joined:
    Oct 25, 2009
    Posts:
    105
    Sensitivity is much better now.

    Some questions/suggestions

    For a realistic car deformation, you should look into also deforming the top of the car. Whenever I land upside down, nothing happens to the car roof.

    Have you also implemented different materials and how they react to deformation? While repeatedly hitting the front of the car, the engine block should stay fairly intact, because it's a massive amount of metal, while the back and sides of the car should deform more easily.
     
  12. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Nice, better. I would still increase sensitivity a bit, though.
    Still running at 170 Km/h into a concrete wall would mean a complete car squash :D
     
  13. inspiredreality

    inspiredreality

    Joined:
    May 30, 2010
    Posts:
    7
    very cool! 8)
    Ron
     
  14. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    Pretty darn cool.
     
  15. satrio

    satrio

    Joined:
    Mar 6, 2010
    Posts:
    101
    Wow! this is cool. I like that the engine sounds like a moped.

     
  16. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,099
    Will your scripts for this work in Unity Indie? or would us developers need to own a pro version?
     
  17. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    satrio: it's from a moped :D you have good ears!

    MakerOfGames: it will work for indy, too. It's just one script which manipulates the vertices of the mesh.
     
  18. brookbake

    brookbake

    Joined:
    Jun 3, 2010
    Posts:
    1
    can anyone tell me how this type of mesh deformations can be implemented under the hood?
     
  19. hacees_gnihk

    hacees_gnihk

    Joined:
    Jan 25, 2010
    Posts:
    45
    Hi Ethan,

    What's the update of your project? Is it already stable? If you don't have the will to share it, may I know the cost of it.. I just need an idea of mesh deformations for my game..

    Thanks
     
  20. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    Hi,

    i am now releasing the code and the whole example project.

    If this package helps you, if you are using it in a commercial project or if you want/need support, i would be happy if you consider a small donation.

    download/donate here: http://vidiludi.com/unity3d-prefabs/

    You will find a detailed description of the script in the readme file.

    Have fun, hope it helps you :)
     
  21. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,099
    Thank you! After reading this thread I started looking at how to implement a system like this myself(and realized its much harder than it seems.) With your code base I hope I can make something very functional for my game project. :) Thanks again!
     
  22. Slem

    Slem

    Joined:
    Jan 28, 2009
    Posts:
    191
    I get a "403 forbidden" message when trying to go to that link. The root url is also denied.
     
  23. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Me too :roll:
     
  24. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    sorry i just failed at changing to permalinks :oops:

    now it works again
     
  25. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    The script is awesome and you rock! Thank you for sharing it with the community :)
     
  26. wbokunic

    wbokunic

    Joined:
    Dec 17, 2009
    Posts:
    43
    Might have found a slight bug. I ended up hitting the ramp at such a speed I was launched really high up, then when I fell the mesh got so deformed I couldn't drive it anymore. Either that or I just hit the ground so hard to wheels got stuck under it.



     
  27. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    psychicparrot:

    thx ;)
    I first thought about selling it, but well ... if someone finds it useful he could still donate.

    wbokunic:

    The wheels are under the ground! That's more like a car physics problem ;)
    It might not be the best car script ever.
     
  28. defjr

    defjr

    Joined:
    Apr 27, 2009
    Posts:
    436
    This is badass! You're the man, Ethan!
     
  29. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    The easiest way to keep the wheels out of the ground is to move the bottom of your car body collision down so that the body will ground before the wheels go through.

    Cheers!
     
  30. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    I've recently been messing around with the car tutorial (me and a hundred others!) so I put the damage script in there tonight to see how it'd do. I think it's great!

    http://psychicparrotgames.com/blog/?p=116

    Still a long way before it becomes a proper game, but hey it's quite fun just driving around bashing into the AI :)

    Cheers!
    Jeff.
     
  31. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    thanks for the kind words on your blog ;)

    looks cool in the game :D
     
  32. Tannz0rz

    Tannz0rz

    Joined:
    May 17, 2010
    Posts:
    18
    Far simpler than I imagined (which is definitely a good thing!) Great work Ethan. :D
     
  33. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    thanks :)

    If anyone makes some cool improvements or extensions, please post a demo or source!
    8)
     
  34. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    I roll my wheels back and have a part of your code in my work for agressive deformation simulations. (When the car falls from height, for example).
    But for precision damage, your code is inapplicable.

    And, if I'll have a sales, I promise to donate your work. Thank you. :wink:

    P.S. I have altered code on 50 %
    But, sorry, I can't share modidfied variant right now.
     
  35. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    I'm glad i could help.

    Hope you have success with it :)
     
  36. hacees_gnihk

    hacees_gnihk

    Joined:
    Jan 25, 2010
    Posts:
    45
    Thanks a lot Ethan for sharing.. We all know that after mesh deformation we should modify the car collider as well.. Anybody who has the idea on how to update a box collider of the car after the deformation?
     
  37. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    If i would have to guess i would say you'd have to sync transform.collider.bounds with the bounds of your deformed mesh (mesh.bounds). 8)
     
  38. Deleted User

    Deleted User

    Guest

    does this work on iphone?
     
  39. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    I dont see a reason why it shouldnt
     
  40. GeneralGrant

    GeneralGrant

    Joined:
    Jun 10, 2010
    Posts:
    977
    Awesome!

    perhaps something that lets the axles bend?
     
  41. stigisimo

    stigisimo

    Joined:
    Jun 3, 2010
    Posts:
    3
    Hi Ethan, can you really help me out?

    Can you say where to apply the car deformation script, because i have it added in car tutorial, next to car controller script but nothing happens?

    Thanks!
     
  42. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    You will need to add the "Body" gameObject (the actual car body mesh gameObject, not your car gameObject) to the Optional Mesh List in the inspector window for Ethan's script.

    The Optional Mesh List means that it will modify specified meshes. If you leave that blank, it will try and modify the mesh attached to the gameObject you have the script attached to - since there is no mesh attached to that car gameObject, it won't do anything.

    Hope that helps.
     
  43. stigisimo

    stigisimo

    Joined:
    Jun 3, 2010
    Posts:
    3
    Thanks!!!
     
  44. efge

    efge

    Joined:
    Dec 13, 2007
    Posts:
    62
    Thanks a lot! I owe you a beer!
     
  45. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    I think quite a few people owe Ethan a beer (I've seen meshes getting impacty squashed all over the place recently!) :)

    There *is* a donation box on his website - I'm sure it takes beer money!

    Jeff.
     
  46. tatelax

    tatelax

    Joined:
    Feb 4, 2010
    Posts:
    1,168
    Lol this is awesome. definitely increase the sensitivity.
     
  47. efge

    efge

    Joined:
    Dec 13, 2007
    Posts:
    62
    ... but I am able to buy him one.
    (I see him every weekday.) 8)
     
  48. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    Awesome! Makes me wish I was in Munich right now ...
     
  49. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    efge: unfortunately we don't have a beer machine at work :(

    Yes, munich is the unofficial unity central ;)
     
  50. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    Hehe last time I went to Munich, it was the unofficial beer central too! :D