Advertisement
Guest User

Untitled

a guest
Sep 8th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1.  public class Dash : Ability
  2.  
  3.     {
  4.  
  5.         protected override void AbilityStarted()
  6.         {
  7.             base.AbilityStarted();
  8.  
  9.             var vel = new Vector3(m_CharacterLocomotion.LocomotionVelocity.x, 0 , m_CharacterLocomotion.LocomotionVelocity.z);
  10.             var lookDir = m_CharacterLocomotion.LookSource.LookDirection(false);
  11.             var lookDirNoY = new Vector3(lookDir.x, 0, lookDir.z);
  12.  
  13.             var inputForce = new Vector3(m_CharacterLocomotion.InputVector.x, 0, m_CharacterLocomotion.InputVector.y);
  14.  
  15.             if (inputForce.x != 0)
  16.             {
  17.                 AddForce(vel.normalized * 50);
  18.                 return;
  19.             }
  20.  
  21.  
  22.             if (inputForce.z < 0) //Back - not a good solution, Id rather use vel.normalized
  23.  
  24.             {
  25.                 AddForce(-m_CharacterLocomotion.transform.forward * 50);
  26.                 return;
  27.             }
  28.  
  29.  
  30.  
  31.             if (inputForce.z > 0) //Forward
  32.             {
  33.                 AddForce(lookDirNoY * 60);
  34.             }
  35.  
  36.         }
  37.  
  38.     }
  39.  
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement