Search Unity

FPSwalkerEnhanced with reduced air control

Discussion in 'Scripting' started by TumbaBit, Apr 2, 2014.

  1. TumbaBit

    TumbaBit

    Joined:
    Feb 17, 2013
    Posts:
    9
    I'm currently using a modified version of FPSwalkerEnhanced for my FPS character controller, and I'm trying to figure out how to make it so a player has a bit of air control, but not full control, as the original script allows for. The script I'm basing this on can be found here (http://wiki.unity3d.com/index.php?title=FPSWalkerEnhanced) and I'm using javascript. A variable for changing how much control the player has would be nice. Thanks.
     
  2. XDrakkir

    XDrakkir

    Joined:
    Oct 26, 2013
    Posts:
    8
    You should see code in the FPSwalkerEnanced script that looks like this.

    Code (csharp):
    1.  
    2. if (airControl  playerControl) { moveDirection.x = inputX * speed * inputModifyFactor;
    3.  moveDirection.z = inputY * speed * inputModifyFactor;
    4.  moveDirection = myTransform.TransformDirection(moveDirection);
    5.  }
    6.  }
    7.  
    replace ONLY that with this.
    Code (csharp):
    1.    
    2.  
    3. float limiter = 3;
    4.  
    5. if (airControl  playerControl) { moveDirection.x = inputX * speed * inputModifyFactor / limiter;
    6.  moveDirection.z = inputY * speed * inputModifyFactor / limiter;
    7.  moveDirection = myTransform.TransformDirection(moveDirection);
    8.  }
    9.  }
    10.  
    11.    
    What this does is divide the movement by 3 or whatever you change limiter to.
     
    Last edited: Apr 3, 2014
  3. TumbaBit

    TumbaBit

    Joined:
    Feb 17, 2013
    Posts:
    9
    Thank for posting, but there's a problem with this code. It does give me limited air control, but whenever I jump I slow down in mid air. I need something that will limit only the speed that will be added to some direction by the player. I hope you, or someone else, can help. Thanks!
     
  4. XDrakkir

    XDrakkir

    Joined:
    Oct 26, 2013
    Posts:
    8
    ah found the problem. what you do is you only divide by speed. so replace speed with (speed / limiter) in the original quote. Please let me know if that fixed it. If it still doesn't work I will check it and get a working script for you.
     
    Last edited: Apr 7, 2014