Exemple #1
0
    public override void Move(CharacterController controller, Transform transform)
    {
        rotateDirection.Set(InputRotateX.SetFloat(), InputRotateY.SetFloat(), InputRotateZ.SetFloat());
        transform.Rotate(rotateDirection);

        moveDirection.Set(InputX.SetFloat(), InputY.SetFloat(), InputZ.SetFloat());         //changed y from InputY.SetFloat()
        if (!controller.isGrounded)
        {
            moveDirection.y -= gravity * Time.deltaTime;
//			Debug.Log("Gravity!" + moveDirection.y);
        }

        moveDirection = transform.TransformDirection(moveDirection);

        if (moveSpeedMultiplier != null)
        {
            moveDirection *= speed * moveSpeedMultiplier.FloatValue;
        }
        else
        {
            moveDirection *= speed;
        }

        if (JumpInput.SetFloat() != 0)
        {
            moveDirection.y = JumpInput.SetFloat();
        }

        //Debug.Log(moveDirection);
        controller.Move(moveDirection * Time.deltaTime);
    }
 void DetectJumpInput()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         JumpInput?.Invoke();
     }
 }
Exemple #3
0
 void DetectJumpInput()
 {
     //check for Spacebar press
     if (Input.GetKeyDown(KeyCode.Space))
     {
         JumpInput?.Invoke();
     }
 }
Exemple #4
0
 void DetectJumpInput()
 {
     //spacebar is pressed
     if (Input.GetKeyDown(KeyCode.Space))
     {
         JumpInput?.Invoke();
     }
 }
Exemple #5
0
 void DetectJumpInput()
 {
     if (Input.GetAxisRaw("Jump") > 0)
     {
         if (!_jmp)
         {
             _jmp = true;
             JumpInput?.Invoke();
         }
     }
     if (Input.GetAxisRaw("Jump") == 0)
     {
         _jmp = false;
     }
 }
    public override void Move(CharacterController controller, Transform transform)
    {
        if (controller.isGrounded)
        {
            rotateDirection.Set(InputRotateX.SetFloat(), InputRotateY.SetFloat(), InputRotateZ.SetFloat());
            transform.Rotate(rotateDirection);

            moveDirection.Set(InputX.SetFloat(), InputY.SetFloat(), InputZ.SetFloat());
            moveDirection = transform.TransformDirection(moveDirection);

            moveDirection  *= speed;
            moveDirection.y = JumpInput.SetFloat();
        }
        moveDirection.y -= gravity * Time.deltaTime;
        controller.Move(moveDirection * Time.deltaTime);
    }
 void DetectJumpInput()
 {
     if (Input.GetMouseButtonDown(1))
     {
         if (_audioSource.isPlaying == false)
         {
             _audioSource.Play();
         }
     }
     else if (Input.GetMouseButtonUp(1))
     {
         if (_audioSource.isPlaying)
         {
             _audioSource.Stop();
         }
     }
     //Right mouse button press
     if (Input.GetMouseButton(1))
     {
         JumpInput?.Invoke();
     }
 }
Exemple #8
0
 public static Vector2 Execute(JumpInput input)
 {
     return(Vector2.up * input.JumpVelocity);
 }
    void Awake()
    {

        jumpInput = GameObject.FindObjectOfType<JumpInput>();
    }