Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. @name Steering plate
  2. @inputs [Car]:entity A D
  3. @outputs
  4. @persist OffsetAng Dir Plate:entity TURNING_ANGLE_MAX TURNING_SPEED TURNING_BACK_SPEED
  5. @model models/hunter/plates/plate1x1.mdl
  6.  
  7. if(first())
  8. {
  9.  
  10. TURNING_SPEED = 1 # The speed your wheels will turn
  11. TURNING_BACK_SPEED = 2 # The speed your wheels will go back to their position
  12. TURNING_ANGLE_MAX = 29.5
  13.  
  14. OffsetAng = 0
  15. Plate:setMass(50000)
  16. runOnTick(1)
  17. Plate = entity()
  18.  
  19. }
  20. elseif(tickClk() & Plate:isFrozen() & !Plate:isPlayerHolding())
  21. {
  22.  
  23. Dir += (A ? 1 : 0) * TURNING_SPEED
  24. Dir -= (D ? 1 : 0) * TURNING_SPEED
  25.  
  26. Dir = clamp( Dir, -TURNING_ANGLE_MAX, TURNING_ANGLE_MAX)
  27.  
  28. if( Dir & !A & !D )
  29. {
  30. if( Dir > 0 )
  31. {
  32. Dir = clamp( Dir-TURNING_BACK_SPEED, 0, Dir )
  33. }
  34. else
  35. {
  36. Dir = clamp( Dir+TURNING_BACK_SPEED, Dir, 0 )
  37. }
  38. }
  39.  
  40. local Ang = Car:toWorld( ang( 0, Dir, 0 ) )
  41.  
  42. #local QuatAngToPlate = quat( Ang ) * inv( quat( Plate ) )
  43. #local Torque = Plate:toLocal( rotationVector( QuatAngToPlate ) + Plate:pos() )
  44.  
  45. #Plate:applyTorque( (Torque * 1000 - Plate:angVelVector() * 40 ) * Plate:inertia())
  46. Plate:setAng( Ang )
  47.  
  48. }
  49. elseif( tickClk() & !Plate:isPlayerHolding() & !Plate:isFrozen())
  50. {
  51. Plate:propFreeze(1)
  52. }
  53. elseif( dupefinished() )
  54. {
  55. reset()
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement