Hinge (Lever, Door, Chest)

A non physics based hinge using Udon, you can use it for doors, hinges, levers, etc.


https://youtu.be/GAsZvTPqkm4

Features:

  • Door, lever and chest example
  • Event and program variable for angle changed
  • Custom min max angle
  • Audio on grab, drop, tick
  • Haptics playing whilst grabbed

Issues:

  • Networking might have some issues, haven’t tested it yet.
  • As there’s no null checking or zero element arrays in udon yet, you will have to remove the audio / recievers or insert dummy elements if you do not want these features.
  • Graph performance has degraded quite a bit with this amount of nodes, doesn’t seem to have much of an in game performance impact.
  • At the moment it is hardcoded to use local X/Y Delta for the handle and a Roll rotation (z) for the lever root, this requires the handle and lever to share the same root, the root is then rotated to change the overall rotational axis.
  • As it is not physically based it can go through other objects, use the angle min/max to mitigate this.
  • I’ve added a visualizer for the angles, but it only updates manually when you check a bool as it uses reflection.
  • I ended up using a while loop instead of a for as I couldn’t get for loops to iterate over udon behaviours (thanks Denwa for the while loop graph)

Package: https://drive.google.com/open?id=1x0dEgIwpyxq4FMJdIyRCLb5TfcCJms9r

Graph:

Code

AO1d2W5bx5b9lUDPqqDmIUAeEjuda9zkJoiH+3ARGLuqdtnqyKRBUkmEJF/WD/1J/Qu9ixQPKbJEVWLRPnIEG7YoTnX2uPZ4/u9//ve3k5/h/AJPPvvPbyfl4vz8X/CGHpx8jYuXL2B2BvEcT05PLs4y/ZJjiVoazbIWkWnNBQvFGWYBrHHJRwGcXvx2Oj9bnE0nJ5/9dvLryWdCev0pPz25PPlMcf4p/+P0ZDLN+PzJ4zl968nJj6cn5Xz6y9XjH1fPvqiHmi9PdTE5W1x+F/8b0+LF6qi/nZxN5guYJHzy+OSz+oHzxexs8urq6ZOnl/MFvvn06fKXp5+8mafp7Pwsnn7yAmdzOtjndJ765/STRxfni4sZfj7Bi8UMzk8/+f4inp+lf+Lls+lPOPk8OgcmGSuC0sh9+D0V76W1hnHnC9OyeBZ1dCxGUbRIPgfvTv748Y/Ta9RcHegpneYcP335cvr25fMJzC6/PZtczF++3H72+qOB8l6DtwIy88kppnniL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Tfl2DoN0meODWyQehkFInleDAQ/jIB9vZNerUF2WrVEUCg+3NLimUBeLPP1l8qBRH69GXSurPiZmb0VJqEohZ6tU3SIVJXlWNJklcAV09LXFqFXhkvpAMnk3Fu9JWHd72WZfW9eeu4P7ZT5cYvYoU07jk8x0bR/k6PR5pGbm3Y91DF6ek0eGWZ/nHrowt+YlOvreDicTHhw3ceEb/BlnX8IoSwkjVad75bX7tKnr9hWtkuQHLUqOjwdLbfoHQl7t8B6h8D7o1N0h4cez6aa7MJbInQSKHG2R5JDq7ThrjU8Xby1FmBFbq73ZZolrxz0Bulr3bgPB69PvLIPLCayuaSyDqXYuSkK/ynpmVDSevlZi85ZL4c+cv6thaP/8P/7x/w== 

Thanks also to Phaxenor for clearing up some misconceptions about program variables and to everyone in the discord for answering questions.

5 Likes

This is great! Glad to see it works so well. Physics doors were always so janky!

Though I do wonder how well it works in a multiplayer environment!

1 Like

For some reason the execution flow input and/or outputs don’t exist anymore on mathf.Clamp and mathf.Atan2 which breaks this whole thing. Just thought I’d point it out for anyone else looking into this.

1 Like