Advertisement
Lucas_3D

Untitled

Feb 14th, 2023 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. /*
  2. Suspension MAXScript
  3. One dummy is at the location of a wheel,
  4. another dummy is a child at the same location, it will move up and down (relatively) and is the suspension dummy.
  5. The actual wheel should be a child of the suspension dummy.
  6. A ray intersects the terrain object from the wheel dummy in it's correct Z direction.
  7. We move the suspension dummy so that the distance from the hitpoint to the wheel position is ideal.
  8. I do this every nth frame to allow for a smoother suspension animation.
  9. */
  10.  
  11. fn CreateSuspension _wheelDummy _susDummy _terrain _wheelRadius =
  12. (
  13. for i = 0 to animationRange.end by 5 do
  14. (
  15. with animate on at time i
  16. try
  17. (
  18. --local allowance = _wheelRadius / 2.0
  19. local myRay = ray _wheelDummy.pos (-1 * normalize(_susDummy.transform[3]))
  20. local rayHit = intersectRay _terrain myRay
  21. local suspensionDistance = ((distance _wheelDummy.pos rayHit.pos) - _wheelRadius)
  22. _susDummy.pos = _wheelDummy.pos - (suspensionDistance * normalize(_susDummy.transform[3]))
  23. ) catch()
  24. )
  25. )
  26. /*
  27. CreateSuspension $backWheelDummy $backSuspensionDummy $'TIN_POI-001' 0.6
  28. CreateSuspension $midWheelDummy $midSuspensionDummy $'TIN_POI-001' 0.6
  29. CreateSuspension $frontWheelDummy $frontSuspensionDummy $'TIN_POI-001' 0.6
  30.  
  31. /*
  32. CreateSuspension $dum_wheel_position $dum_suspension $terrain 0.5
  33. CreateSuspension $dum_wheel_position001 $dum_suspension001 $terrain 0.5
  34.  
  35. /*
  36. I should use the allowance variable conditionally which restricts how far the suspension can move and create a case for when it is false.
  37. I don't think the ray is being cast at a good location, it should be cast from the most distance wheel location, to allow for the greatest chance of a terrain hit.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement