Move() public method

public Move ( float h ) : void
h float
return void
Esempio n. 1
0
 void Update()
 {
     if (Input.anyKey)
     {
         if (Input.GetKey(keys[(int)Dir.up]))
         {
             anotherScript.Move((int)Dir.up);
         }
         if (Input.GetKey(keys[(int)Dir.down]))
         {
             anotherScript.Move((int)Dir.down);
         }
         if (Input.GetKey(keys[(int)Dir.left]))
         {
             anotherScript.Move((int)Dir.left);
         }
         if (Input.GetKey(keys[(int)Dir.right]))
         {
             anotherScript.Move((int)Dir.right);
         }
     }
     else
     {
         anotherScript.Move((int)Dir.idle);
     }
 }
Esempio n. 2
0
    void FixedUpdate()
    {
        //Move our character
        controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);

        jump = false;
    }
Esempio n. 3
0
    void Update()
    {
        // 이동 입력
        Vector3 moveInput    = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
        Vector3 moveVelocity = moveInput.normalized * moveSpeed;

        controller.Move(moveVelocity);

        // 바라보기 입력
        Ray   ray         = viewCamera.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
        float rayDistance;

        if (groundPlane.Raycast(ray, out rayDistance))
        {
            Vector3 point = ray.GetPoint(rayDistance);
            // Debug.DrawLine(ray.origin, point, Color.red);
            controller.LookAt(point);
        }

        // 무기 입력
        if (Input.GetMouseButton(0))
        {
            gunController.Shoot();
        }
    }
Esempio n. 4
0
    void Update()
    {
        Vector2 gravDir = ((Vector2)transform.position - zeroPoint).normalized; //Vector2 gravDir = -Vector2.up;

        #region Deprecated

        /*Vector2 mouse = Input.mousePosition;
         * Vector2 screenPoint = Camera.main.WorldToScreenPoint(transform.position); //Gets Screen co-ordinates of our plane
         * Vector2 offset = (mouse - screenPoint); //new Vector2(mouse.x - screenPoint.x, mouse.y - screenPoint.y);
         * float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg;
         * transform.rotation = Quaternion.Euler(0, 0, angle);
         *
         * //Debug.DrawRay(transform.position, transform.up, Color.blue);
         *
         * //Debug.DrawRay(transform.position, gravDir, Color.red);
         */
        #endregion

        Vector2 mouseOnScreen  = Camera.main.ScreenToViewportPoint(Input.mousePosition);                                   //Gets Screen position of the mouse
        Vector2 playerOnScreen = Camera.main.WorldToViewportPoint(transform.position);                                     //Gets Screen position of the player

        float angle = Mathf.Atan2(playerOnScreen.y - mouseOnScreen.y, playerOnScreen.x - mouseOnScreen.x) * Mathf.Rad2Deg; //Gets Angle between mouse and player
        transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, angle + 90));                                            //Sets Rotation of player according to our angle

        Debug.DrawRay(transform.position, transform.up, Color.blue);

        if (Input.GetButtonDown("Fire1"))
        {
            //rigid.AddForce(-transform.up * thrustForce);
        }
        velocity += (gravDir * gravity) * Time.smoothDeltaTime;
        controller.Move(velocity * Time.deltaTime);
    }
Esempio n. 5
0
 void FixedUpdate()
 {
     // interprets the controls to the script
     controller.Move(horizontalMove * Time.fixedDeltaTime, jump);
     attacker.Attack(horizontalMove != 0, attack);
     jump   = false;
     attack = false;
 }
Esempio n. 6
0
    void Update()
    {
        //Movement Input
        Vector3 moveInput    = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
        Vector3 moveVelocity = moveInput.normalized * moveSpeed;

        controller.Move(moveVelocity);

        //Look Input
        Ray   ray         = viewCamera.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up, Vector3.up * gunController.GunHeight);
        float rayDistance;

        if (groundPlane.Raycast(ray, out rayDistance))
        {
            Vector3 pointOfIntersection = ray.GetPoint(rayDistance);
            //Debug.DrawLine(ray.origin, pointOfIntersection, Color.red);
            controller.LookAt(pointOfIntersection);
            crossHairs.transform.position = pointOfIntersection;
            crossHairs.DetectTarget(ray);
            if ((new Vector2(pointOfIntersection.x, pointOfIntersection.z) - new Vector2(transform.position.x, transform.position.z)).sqrMagnitude > Mathf.Pow(1.9f, 2f))
            {
                gunController.Aim(pointOfIntersection);
            }
        }

        //Weapon Input
        if (Input.GetMouseButton(0))
        {
            gunController.OnTriggerHold();
        }
        if (Input.GetMouseButtonUp(0))
        {
            gunController.OnTriggerRelease();
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            gunController.Reload();
        }

        if (transform.position.y < -10)
        {
            TakeDamage(health);
        }

        if (Input.GetMouseButtonDown(1))
        {
            if (numOfGrenades != 0)
            {
                Launch();
                numOfGrenades--;
            }
        }
    }
Esempio n. 7
0
 public void MovePlayer(Direction direction, int playerIndex)
 {
     if (playerIndex == 1)
     {
         player1.Move(direction);
     }
     else if (playerIndex == 2)
     {
         player2.Move(direction);
     }
 }
Esempio n. 8
0
 void FixedUpdate()
 {
     if (!inversao)
     {
         controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);
     }
     else
     {
         controller.Move((-1 * horizontalMove) * Time.fixedDeltaTime, false, jump);
     }
     if (horizontalMove != 0)
     {
         animator.SetBool("Run", true);
     }
     else
     {
         animator.SetBool("Run", false);
     }
     jump = false;
 }
Esempio n. 9
0
    void RightMouseButtonDown()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, enemyLayerMask))
        {
            player.Attack(hit.collider.transform);
        }
        else if (Physics.Raycast(ray, out hit, Mathf.Infinity, groundLayerMask))
        {
            player.Move(new Vector2(hit.point.x, hit.point.z));
        }
    }
Esempio n. 10
0
    // movement state
    public void CalculateMove()
    {
        //calculate possible moves
        sMovePath m_PossibleMoves = GetPossibleMoves(m_PlayerControl.m_CurrentX, m_PlayerControl.m_CurrentY);

        // if only one move left, simply go there
        if (m_PossibleMoves.m_AvailableMoves.Count == 1)
        {
            m_PlayerControl.Move((int)m_PossibleMoves.m_AvailableMoves [0].transform.position.x, (int)m_PossibleMoves.m_AvailableMoves [0].transform.position.y);
        }
        else if (m_PossibleMoves.m_AvailableMoves.Count == 0)         // if no moves left, AI loses game
        {
            m_PlayerControl.m_State = WizardState.Dead;
            m_PlayerControl.m_Manager.GameOver();
            return;
        }

        List <sMovePath> m_MoveList = new List <sMovePath>();

        // check moves after next
        foreach (TileManager tile in m_PossibleMoves.m_AvailableMoves)
        {
            m_MoveList.Add(GetPossibleMoves((int)tile.transform.position.x, (int)tile.transform.position.y));
        }

        // sort list so that movement with most options next turn is first in the list
        m_MoveList.Sort(delegate(sMovePath x, sMovePath y) {
            return(x.m_AvailableMoves.Count - y.m_AvailableMoves.Count);
        }
                        );

        // move to tile with most available future options
        m_PlayerControl.Move((int)m_MoveList [0].x, (int)m_MoveList [0].y);

        StartCoroutine(DelayAI());
    }
Esempio n. 11
0
 void FixedUpdate()
 {
     Move();
     move *= speed;
     pc.Move(move, jump);
 }
Esempio n. 12
0
 void FixedUpdate()
 {
     // Liikuttaa hahmoa
     controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
     jump = false;
 }
Esempio n. 13
0
 private void FixedUpdate()
 {
     controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);
     jump = false;
 }
 public void LeftArrow()
 {
     player.Move(-1);
     moveInput = -1;
 }