コード例 #1
0
ファイル: Movement.cs プロジェクト: ztoma2420/EDDProject
 void ZachMovement(float zachspeed, int animationstate, bool isjump, int direction) //determines which way the model should be facing, the current movement speed and direction, and what animation is being played. verifies the unlockkey matches if movement is locked
 {                                                                                  //extra note: direction should either be 1 or -1; 1 if going a positive direction, -1 if going a negative direction
     if (!isjump && !islocked || !isjump && animationstate == unlockkey)
     {
         keyPress = true;
         mvnt.MoveAlongX(zachspeed * Time.deltaTime * direction);
         animator.SetInteger("AnimationState", animationstate);
         if (facingright)
         {
             spriteRenderer.flipX = false;
         }
         else
         {
             spriteRenderer.flipX = true;
         }
     }
     if (isjump && !islocked || isjump && animationstate == unlockkey)
     {
         keyPress = true;
         mvnt.MoveAlongY(zachspeed * Time.deltaTime * direction);
         animator.SetInteger("AnimationState", animationstate);
         if (facingright)
         {
             spriteRenderer.flipX = false;
         }
         else
         {
             spriteRenderer.flipX = true;
         }
     }
 }
コード例 #2
0
 private void Update()
 {
     mvnt.MoveAlongX(Input.GetAxis("P1X") * Distance * Time.deltaTime);
     mvnt.MoveAlongY(Input.GetAxis("JumpP1") * Distance * Time.deltaTime);
     if (Input.GetKeyDown(KeyCode.Space))
     {
         mvnt.SmoothGridMove(Vector2.right, Distance, false);
     }
 }
コード例 #3
0
ファイル: MovingObject.cs プロジェクト: ekandlen/warcopters
    protected void Update()
    {
        if (Velocity <= 0 || (Dh == 0 && Dv == 0))
        {
            return;
        }
        // Debug.Log("MO.Update" + Dh);

        var dx    = MoveX ? Dh * Velocity * Time.deltaTime : 0;
        var dy    = MoveY ? Dv * Velocity * Time.deltaTime : 0;
        var moved = false;

        if (Force)
        {
            moved = true;
            if (MoveX)
            {
                _mvnt.ForceMoveAlongX(dx);
            }
            if (MoveY)
            {
                _mvnt.ForceMoveAlongY(dy);
            }
        }
        else
        {
            if (MoveX)
            {
                moved = _mvnt.MoveAlongX(dx) || moved;
            }
            if (MoveY)
            {
                moved = _mvnt.MoveAlongY(dy) || moved;
            }
        }
        var distance = Mathf.Sqrt(dx * dx + dy * dy);

        RemainingDistance -= distance;
        if (RemainingDistance <= 0)
        {
            StopMoving();
        }
        OnMove(distance, moved);
        if (Input.GetKeyDown(KeyCode.Space))
        {
            // Mvnt.SmoothGridMove(Vector2.right, Distance, false);
        }
    }