Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Steering plate
- @inputs [Car]:entity A D
- @outputs
- @persist OffsetAng Dir Plate:entity TURNING_ANGLE_MAX TURNING_SPEED TURNING_BACK_SPEED
- @model models/hunter/plates/plate1x1.mdl
- if(first())
- {
- TURNING_SPEED = 1 # The speed your wheels will turn
- TURNING_BACK_SPEED = 2 # The speed your wheels will go back to their position
- TURNING_ANGLE_MAX = 29.5
- OffsetAng = 0
- Plate:setMass(50000)
- runOnTick(1)
- Plate = entity()
- }
- elseif(tickClk() & Plate:isFrozen() & !Plate:isPlayerHolding())
- {
- Dir += (A ? 1 : 0) * TURNING_SPEED
- Dir -= (D ? 1 : 0) * TURNING_SPEED
- Dir = clamp( Dir, -TURNING_ANGLE_MAX, TURNING_ANGLE_MAX)
- if( Dir & !A & !D )
- {
- if( Dir > 0 )
- {
- Dir = clamp( Dir-TURNING_BACK_SPEED, 0, Dir )
- }
- else
- {
- Dir = clamp( Dir+TURNING_BACK_SPEED, Dir, 0 )
- }
- }
- local Ang = Car:toWorld( ang( 0, Dir, 0 ) )
- #local QuatAngToPlate = quat( Ang ) * inv( quat( Plate ) )
- #local Torque = Plate:toLocal( rotationVector( QuatAngToPlate ) + Plate:pos() )
- #Plate:applyTorque( (Torque * 1000 - Plate:angVelVector() * 40 ) * Plate:inertia())
- Plate:setAng( Ang )
- }
- elseif( tickClk() & !Plate:isPlayerHolding() & !Plate:isFrozen())
- {
- Plate:propFreeze(1)
- }
- elseif( dupefinished() )
- {
- reset()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement