Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Suspension MAXScript
- One dummy is at the location of a wheel,
- another dummy is a child at the same location, it will move up and down (relatively) and is the suspension dummy.
- The actual wheel should be a child of the suspension dummy.
- A ray intersects the terrain object from the wheel dummy in it's correct Z direction.
- We move the suspension dummy so that the distance from the hitpoint to the wheel position is ideal.
- I do this every nth frame to allow for a smoother suspension animation.
- */
- fn CreateSuspension _wheelDummy _susDummy _terrain _wheelRadius =
- (
- for i = 0 to animationRange.end by 5 do
- (
- with animate on at time i
- try
- (
- --local allowance = _wheelRadius / 2.0
- local myRay = ray _wheelDummy.pos (-1 * normalize(_susDummy.transform[3]))
- local rayHit = intersectRay _terrain myRay
- local suspensionDistance = ((distance _wheelDummy.pos rayHit.pos) - _wheelRadius)
- _susDummy.pos = _wheelDummy.pos - (suspensionDistance * normalize(_susDummy.transform[3]))
- ) catch()
- )
- )
- /*
- CreateSuspension $backWheelDummy $backSuspensionDummy $'TIN_POI-001' 0.6
- CreateSuspension $midWheelDummy $midSuspensionDummy $'TIN_POI-001' 0.6
- CreateSuspension $frontWheelDummy $frontSuspensionDummy $'TIN_POI-001' 0.6
- /*
- CreateSuspension $dum_wheel_position $dum_suspension $terrain 0.5
- CreateSuspension $dum_wheel_position001 $dum_suspension001 $terrain 0.5
- /*
- I should use the allowance variable conditionally which restricts how far the suspension can move and create a case for when it is false.
- 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