Guest User

Untitled

a guest
Jan 13th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. @name Hovering plate with ranger
  2. @persist [Vel RDist Height]:number
  3. runOnTick(1) #Refresh's the chip.
  4. E=entity():isWeldedTo()#Get's the prop the entity is placed on aka the plate.
  5.  
  6. #Ranger:
  7. Height=100 #Sets how high you want the plate to be off the ground.
  8. Ranger=ranger(Height) #makes the ranger.
  9. Distance=Ranger:distance() #Get's the Rangers distance.
  10. Ent=Ranger:entity() #Set's the chip to be the ranger.
  11. rangerHitWater(1) #Makes the ranger hit water, set the 1 to an 0 if you don't want it to.
  12. rangerFilter(E) #Stops the ranger from hitting the plate the chip is on.
  13.  
  14. #Vertical hover height
  15. if(RDist<Height){RDist=Height} #Sets how high the plate is off the ground.
  16.  
  17. #More Ranger stuff
  18. Rng=rangerOffset(E:pos(),E:pos()-vec(0,0,RDist))
  19. if(Rng:hit()){ #Detects if the ranger hits the ground
  20. Diff=RDist-Rng:distance() #Get's the difference between the distance to the ground and the distance the chip is off the ground.
  21. E:applyForce((vec(0,0,Diff)*20-E:vel())*E:mass()*6/100)} #Applies force to the plate and negates any excess sway.
  22.  
  23. #Stabilisation the plate
  24. P=E:angles():pitch() #Get's the plates Pitch
  25. Y=0 #Sets the yaw to 0 so you can rotate it later on if you want.
  26. R=E:angles():roll() #Get's the plates Yaw
  27. Gyro=angnorm(ang(0,0,0)-ang(P,Y,R))*E:mass()*5 #Takes the angles of the plate and subtracts them to make the plate flat.
  28. E:applyAngForce(Gyro+$Gyro) #Applies angular force to the plate to make it flat.
  29.  
  30. #Stabilisation part 2 and rotational smoothing
  31. AngVel = E:angVel() #Get's the plates angular velocity e.g. How fast it's spinning/turning
  32. AngForce=-ang(AngVel:pitch()*E:mass(),AngVel:yaw()*20,AngVel:roll()*10) #Defines Angforce as the opposite direction the plate is turning
  33. E:applyAngForce(AngForce) #Applies angular force to the opposite direction to make the plate stop turning.
  34.  
  35. #=======Instructions=======
  36. # Spawn a 1x2 Plate
  37. # Spawn the E2 chip on the plate
Advertisement
Add Comment
Please, Sign In to add comment