Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

truck and trailer

Discussion in 'Scripting' started by devilkkw, Jun 3, 2011.

  1. devilkkw

    devilkkw

    Joined:
    Jun 24, 2009
    Posts:
    175
    hi all.i've a question:
    i've a truck in my scene,i've created script form move it.
    now i want to make possibility of attach or detach trailer.
    what is correct way?
     
  2. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    Attachment...

    First align your trailer to the hitch point. Second create a customized joint that handles rotation in the Y axis from -120 to 120 degrees, X and Z axis are both -10 to 10. Set the breakpoint to about 10 times the weight of the trailer. (I think it may be more) Set the rigid bodies.

    Detachment...

    Destroy the joint

    I posted the exact joint you need in a previous thread. ;) It assumes that the trailer is going the same direction as the truck, you would have to do some angle calculation to fix it. (I have gotten better at Unity since then... lol )

    http://forum.unity3d.com/threads/68742-truck-making-tutorial.?p=439426&viewfull=1#post439426
     
  3. devilkkw

    devilkkw

    Joined:
    Jun 24, 2009
    Posts:
    175
    thank's for fast reply.i try it..
    for apply i think have to script the trailer.it's correct?
     
  4. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    yeah, there was a bunch more to it, but basically it goes on a trailer and references the fifth wheel point. Probably more, but I can't remember..;)
     
  5. devilkkw

    devilkkw

    Joined:
    Jun 24, 2009
    Posts:
    175
    it's hard to me.can post example?