Advertisement
peacestorm

autowalk code

Sep 27th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function toDirectionalVector(vector, yaw, pitch) { //some parts of this function are made by @zhuowei
  2.     vector[0] = Math.cos(yaw) * Math.cos(0);
  3.     vector[1] = Math.sin(pitch);
  4.     vector[2] = Math.sin(yaw) * Math.cos(0);
  5. }
  6.  
  7. var playerDir = [0, 0, 0];
  8. var DEG_TO_RAD = Math.PI / 180;
  9. var playerWalkSpeed = 0.2;
  10.  
  11. var autoWalk = {
  12.     name: "AutoWalk",
  13.     desc: "Makes your player walk automatically.",
  14.     category: VertexClientPE.category.MOVEMENT,
  15.     type: "Mod",
  16.     state: false,
  17.     isStateMod: function() {
  18.         return true;
  19.     },
  20.     onToggle: function() {
  21.         this.state = !this.state;
  22.     },
  23.     onTick: function() {
  24.         toDirectionalVector(playerDir, (getYaw() + 90) * DEG_TO_RAD, getPitch() * DEG_TO_RAD * -1);
  25.         var player = getPlayerEnt();
  26.         setVelX(player, playerWalkSpeed * playerDir[0]);
  27.         if(Player.isFlying()) {
  28.             setVelY(player, playerWalkSpeed * playerDir[1]);    
  29.         }
  30.         setVelZ(player, playerWalkSpeed * playerDir[2]);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement