Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Tiresmoke+Skid V2
- @inputs [Baseplate WheelBL WheelBR]:entity
- @outputs ThrustL ThrustR
- @persist WheelDiameter WheelSpinL WheelSpinR
- @persist SkidVolCoef SkidPitchCoef SkidPitchOffset ThrusterThreshold
- @trigger none
- #Funcitions
- #Funcitions
- function number angVel2LinVel(Prop:entity, Diameter){ #Converts the angular velocity to linear velocity
- return abs((toRad(Prop:angVel():pitch())*Diameter)/2)
- }
- #End of functions
- #End of functions
- if(dupefinished()){reset()}
- interval(50)
- if(first()|dupefinished()) {
- #Tire skid sound setup
- soundPlay("skid",0,"acf_nwhis/misc/tires/skid07.wav")
- soundVolume("skid",0)
- holoCreate(1)
- holoAlpha(1,0)
- #Constants
- WheelDiameter = 30 # Measure with source units
- RideHeight = 19 #Vehicle Distance off ground
- SkidVolCoef = 0.001 # Increase this value to increase loudness
- SkidPitchCoef = 0.035 # Increase this value to make the pitc more sensitive
- SkidPitchOffset = 80 # Increase this value to have a higher initial pitch
- ThrusterThreshold = 400 # Wheelspin value at which the thrusters engage
- }
- Distance = 30
- rangerFilter(Baseplate)
- Ranger = rangerOffset(Distance, Baseplate:toWorld(vec(0,0,-8)), -Baseplate:up())
- holoPos(1,Ranger:position())
- Height = (Ranger:pos()-Baseplate:pos()):length()
- if(Height<RideHeight){On = 1}else{On = 0}
- #Wheel spin calculations
- WheelSpinL = abs(Baseplate:vel():length() - angVel2LinVel(WheelBL,WheelDiameter))
- WheelSpinR = abs(Baseplate:vel():length() - angVel2LinVel(WheelBR,WheelDiameter))
- #Thruster smoke control
- if(WheelSpinL > ThrusterThreshold){ThrustL = 1}
- else{ThrustL = 0}
- if(WheelSpinR > ThrusterThreshold){ThrustR = 1}
- else{ThrustR = 0}
- if(Height<Distance){soundVolume("skid",((WheelSpinL+WheelSpinR)/2)*SkidVolCoef)}else{
- #Sound stuff
- soundVolume("skid",0)
- }
- soundPitch("skid",SkidPitchOffset+((WheelSpinL+WheelSpinR)/2)*SkidPitchCoef)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement