Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Hovering plate with ranger
- @persist [Vel RDist Height]:number
- runOnTick(1) #Refresh's the chip.
- E=entity():isWeldedTo()#Get's the prop the entity is placed on aka the plate.
- #Ranger:
- Height=100 #Sets how high you want the plate to be off the ground.
- Ranger=ranger(Height) #makes the ranger.
- Distance=Ranger:distance() #Get's the Rangers distance.
- Ent=Ranger:entity() #Set's the chip to be the ranger.
- rangerHitWater(1) #Makes the ranger hit water, set the 1 to an 0 if you don't want it to.
- rangerFilter(E) #Stops the ranger from hitting the plate the chip is on.
- #Vertical hover height
- if(RDist<Height){RDist=Height} #Sets how high the plate is off the ground.
- #More Ranger stuff
- Rng=rangerOffset(E:pos(),E:pos()-vec(0,0,RDist))
- if(Rng:hit()){ #Detects if the ranger hits the ground
- Diff=RDist-Rng:distance() #Get's the difference between the distance to the ground and the distance the chip is off the ground.
- E:applyForce((vec(0,0,Diff)*20-E:vel())*E:mass()*6/100)} #Applies force to the plate and negates any excess sway.
- #Stabilisation the plate
- P=E:angles():pitch() #Get's the plates Pitch
- Y=0 #Sets the yaw to 0 so you can rotate it later on if you want.
- R=E:angles():roll() #Get's the plates Yaw
- 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.
- E:applyAngForce(Gyro+$Gyro) #Applies angular force to the plate to make it flat.
- #Stabilisation part 2 and rotational smoothing
- AngVel = E:angVel() #Get's the plates angular velocity e.g. How fast it's spinning/turning
- AngForce=-ang(AngVel:pitch()*E:mass(),AngVel:yaw()*20,AngVel:roll()*10) #Defines Angforce as the opposite direction the plate is turning
- E:applyAngForce(AngForce) #Applies angular force to the opposite direction to make the plate stop turning.
- #=======Instructions=======
- # Spawn a 1x2 Plate
- # Spawn the E2 chip on the plate
Advertisement
Add Comment
Please, Sign In to add comment