Beispiel #1
0
    private void InputDetection()
    {
        var horizontal = SimpleInput.GetAxis("Horizontal");

        if (horizontal < 0f)
        {
            state.HideShield();
            state.MoveLeft();
        }
        else if (horizontal > 0f)
        {
            state.HideShield();
            state.MoveRight();
        }
        else if (horizontal == 0f)
        {
            state.GetIdle();
        }

        var vertical = SimpleInput.GetAxis("Vertical");

        if (SimpleInput.GetButton("Jump") || vertical > 0f)
        {
            state.MoveUp();
        }
        else if (vertical < 0f)
        {
            state.MoveDown();
        }

        if (SimpleInput.GetButton("Fire1"))
        {
            state.HideShield();
            state.UseWeapon();
        }
        else
        {
            if (SimpleInput.GetButtonDown("Fire2"))
            {
                state.UseShield();
            }
            else if (SimpleInput.GetButtonUp("Fire2"))
            {
                state.HideShield();
            }
        }

        if (SimpleInput.GetButton("Jump"))
        {
            GameManager.S.PauseUnpause();
        }

        if (Application.platform == RuntimePlatform.Android)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                GameManager.S.PauseUnpause();
            }
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        Kraftstoffanzeige.value = Kraftstofffloat;

        //Kamrer und Auto drehen
        if (beschleunigen > 0)
        {
            //Lenkungswickel messen
            var z = SimpleInput.GetAxis("Horizontal") * Time.deltaTime * lenkung;
            //auto drehen
            transform.Rotate(0, 0, -z);
        }
        if (beschleunigen < 0)
        {
            //Lenkungswickel messen
            var z = SimpleInput.GetAxis("Horizontal") * Time.deltaTime * lenkung;
            //auto drehen
            transform.Rotate(0, 0, -z);
        }

        //Kamera drehen
        Kamera.GetComponent <Transform>().transform.rotation = this.transform.rotation;

        //Km/h anzeigen
        int kmh = beschleunigen;

        Tempanzeiger.text = kmh + " km/h";

        //Wenn Tank leer GameOver
        if (Kraftstofffloat <= 0)
        {
            GameOverPanel.SetActive(true);
        }
    }
    void Update()
    {
        if (GameManager.instance.IsDronAlive)
        {
            actualPosition = transform.position;
            movex          = SimpleInput.GetAxis("Horizontal");
            moveForward    = SimpleInput.GetAxis("Vertical");
            movey          = SimpleInput.GetAxis("VerticalLift");
            if (Input.GetKeyDown(KeyCode.Space))
            {
                ActivateBoost();
            }
            Move();
            lastPosition    = actualPosition;
            actualPosition  = transform.position;
            playerDirection = actualPosition - lastPosition;

            RotateProps();
            BoostCharging();
            MoveHeightScale();
            BatteryDischarge();
        }
        else
        {
            if (audioSource.pitch > 0)
            {
                audioSource.pitch -= 0.5f * Time.deltaTime;
            }
            CollapseBroken();
        }
    }
    void Update()
    {
        float horizontalInput = SimpleInput.GetAxis("Horizontal");
        float verticalInput   = SimpleInput.GetAxis("Vertical");

        Vector3 move = currentCamera.right * horizontalInput + currentCamera.forward * verticalInput;

        move.y = 0;
        Vector3 moveFinal = move.normalized * speed * Time.deltaTime;

        controller.Move(moveFinal);


        makeGravity();


        if ((horizontalInput != 0) || (verticalInput != 0))
        {
            moving = true;
        }
        if ((horizontalInput == 0) && (verticalInput == 0))
        {
            moving = false;
        }

        animator.SetBool("Moving", moving);
        animator.SetFloat("HorizontalSpeed", horizontalInput);
        animator.SetFloat("VerticalSpeed", verticalInput);
    }
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = SimpleInput.GetAxis("Horizontal");
            float vertical   = SimpleInput.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #6
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            txtAction.text = destinationName;
            if (SimpleInput.GetButtonDown("Vertical") && SimpleInput.GetAxis("Vertical") < 0)
            {
                collision.gameObject.GetComponent <Player>().animator.SetBool("isAssis", true);
                //*** Arrete de mouvement horizontaux ***//
                StaticClass.disableInput = true;

                //*** positionnnement du player assis sur le sprite de la chaise ***//
                //collision.gameObject.GetComponent<SpriteRenderer>().flipX = false;
                //collision.gameObject.transform.position = transform.position;

                chair1 = GameObject.Find("ChairPosition");
                chair2 = GameObject.Find("player-chair");

                Vector3 position = new Vector3(0, 0, 0);
                position.x = chair1.transform.position.x;
                position.y = chair1.transform.position.y;
                position.z = chair1.transform.position.z;
                chair2.transform.position = position;
            }

            if (SimpleInput.GetButtonDown("Vertical") && SimpleInput.GetAxis("Vertical") > 0)
            {
                collision.gameObject.GetComponent <Player>().animator.SetBool("isAssis", false);
                StaticClass.disableInput = false;
            }
        }
    }
Beispiel #7
0
    void Move()
    {
        if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow) || SimpleInput.GetAxis(TagManager.HORIZONTAL_AXIS) < 0)
        {
            myBody.velocity = new Vector2(Mathf.Clamp(-move_Speed, -max_moveSpeed, +max_moveSpeed), myBody.velocity.y);
            goLeft          = true;
            sr.flipX        = goLeft;
        }
        else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow) || SimpleInput.GetAxis(TagManager.HORIZONTAL_AXIS) > 0)
        {
            myBody.velocity = new Vector2(Mathf.Clamp(+move_Speed, -max_moveSpeed, +max_moveSpeed), myBody.velocity.y);
            goLeft          = false;
            sr.flipX        = goLeft;
        }


        // stop input by stopping script
        if (playerHealth.isAlive == false)
        {
            GetComponent <SideScrollerCharacter>().enabled = false;
        }

        if ((first_Jump && boost_Dash) && (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetMouseButton(2))) //middle mouse button
        {
            StartCoroutine(Boost(1.2f));                                                                    //Start the Coroutine called "Boost", and feed it the time we want it to boost us
        }
    }
Beispiel #8
0
    void FixedUpdate()
    {
        //if (grounded)
        move = SimpleInput.GetAxis("Horizontal");
        //else
        //    move = jumpMove;

        anim.SetFloat("Speed", Mathf.Abs(move));
        anim.SetBool("Ground", grounded);
        anim.SetFloat("vSpeed", pRigidBody.velocity.y);
        anim.SetBool("Damaged", damaged);

        if (!damaged && hp > 0)
        {
            pRigidBody.velocity = new Vector2(move * maxSpeed, pRigidBody.velocity.y);
        }

        if (move > 0 && !facingRight)
        {
            Flip();
        }
        else if (move < 0 && facingRight)
        {
            Flip();
        }

        if (jump)
        {
            pRigidBody.AddForce(new Vector2(0f, jumpForce));
            audioSource.clip = jumpSound;
            audioSource.Play();
            jump = false;
        }
    }
Beispiel #9
0
    // Fonction pour gérer le mouvement du joueur
    void Movement()
    {
        float move = SimpleInput.GetAxis("Horizontal");
        float acc  = Input.acceleration.x;

        // Si un déplacement au clavier à été détecté
        if (move != 0)
        {
            rb.velocity = new Vector2(move * speed * Time.deltaTime, rb.velocity.y);
        }
        else
        {
            // On prend le relai avec l'inclinaison du tel
            if (acc > acc_threshold)
            {
                rb.velocity = new Vector2(2 * speed * Time.deltaTime, rb.velocity.y);
            }
            else if (acc < -acc_threshold)
            {
                rb.velocity = new Vector2(-2 * speed * Time.deltaTime, rb.velocity.y);
            }
            else
            {
                rb.velocity = new Vector2(2 * acc * speed * Time.deltaTime, rb.velocity.y);
            }
            acc_t.text = "acc : " + acc.ToString();
        }
    }
Beispiel #10
0
    private void FixedUpdate()
    {
        // pass the input to the airplane!
        float collective_height = SimpleInput.GetAxis("L_Vertical");
        float pedals_rotation   = SimpleInput.GetAxis("L_Horizontal");
        float cyclic_forward    = SimpleInput.GetAxis("R_Vertical");
        float cyclic_sideway    = SimpleInput.GetAxis("R_Horizontal");
        float throttle          = 100.0f;

        if (pcInput)
        {
            collective_height = Input.GetAxis("AirplaneHeight");
            cyclic_forward    = Input.GetAxis("Vertical");
            pedals_rotation   = Input.GetAxis("AirplaneRota");
            cyclic_sideway    = Input.GetAxis("Horizontal");
        }

        collective_height = Mathf.InverseLerp(-1f, 1f, collective_height);
        pedals_rotation   = Mathf.InverseLerp(-1f, 1f, pedals_rotation);

        //Round values
        collective_height = (Mathf.Floor(collective_height * 100f)) / 100f;
        pedals_rotation   = (Mathf.Floor(pedals_rotation * 100f)) / 100f;
        cyclic_forward    = (Mathf.Floor(cyclic_forward * 100f)) / 100f;
        cyclic_sideway    = (Mathf.Floor(cyclic_sideway * 100f)) / 100f;


#if !MOBILE_INPUT
        float handbrake = CrossPlatformInputManager.GetAxis("Jump");
        m_Airplane.Move(h, v, v);
#else
        m_Airplane.Move(collective_height, pedals_rotation, cyclic_forward, cyclic_sideway, throttle);
#endif
    }
Beispiel #11
0
    private void Update()
    {
        if (mover)
        {
            if (Application.isMobilePlatform)
            {
                Vector3 acceleration = SimpleInput.GetAxis("Vertical") * verticalInputAcceleration * transform.up;
                velocity += acceleration * Time.deltaTime;

                // apply turn input
                float zTurnAcceleration = -1 * SimpleInput.GetAxis("Horizontal") * horizontalInputAcceleration;
                zRotationVelocity += zTurnAcceleration * Time.deltaTime;
            }
            else
            {
                Vector3 acceleration = Input.GetAxis("Vertical") * verticalInputAcceleration * transform.up;
                velocity += acceleration * Time.deltaTime;

                // apply turn input
                float zTurnAcceleration = -1 * Input.GetAxis("Horizontal") * horizontalInputAcceleration;
                zRotationVelocity += zTurnAcceleration * Time.deltaTime;
            }
        }
        // apply forward input
    }
    private void UpdateMovement()
    {
        var     xDir      = SimpleInput.GetAxis("Horizontal") + Input.GetAxisRaw("Horizontal");
        var     yDir      = SimpleInput.GetAxis("Vertical") + Input.GetAxisRaw("Vertical");
        Vector3 moveInput = new Vector3(xDir, yDir, 0).normalized;

        moveVelocity = moveInput * speed * Time.deltaTime;

        var checkedPos = rb2d.transform.position + moveVelocity;

        checkedPos.x = Mathf.Clamp(checkedPos.x, followPlayer.minX - followPlayer.thresholdClampX, followPlayer.maxX + followPlayer.thresholdClampX);
        checkedPos.y = Mathf.Clamp(checkedPos.y, followPlayer.minY - followPlayer.thresholdClampY, followPlayer.maxY + followPlayer.thresholdClampY);

        rb2d.transform.position = checkedPos;

        var     xRotate     = SimpleInput.GetAxis("HorizontalRotate");
        var     yRotate     = SimpleInput.GetAxis("VerticalRotate");
        Vector3 rotateInput = new Vector3(xRotate, yRotate, 0).normalized;

        if (moveVelocity != Vector3.zero && rotateInput * speed * Time.deltaTime == Vector3.zero)
        {
            float rot_z = Mathf.Atan2(moveInput.normalized.y, moveInput.normalized.x) * Mathf.Rad2Deg;
            transform.rotation = Quaternion.Euler(0f, 0f, rot_z);
        }
        else if (rotateInput * speed * Time.deltaTime != Vector3.zero)
        {
            float rot_z = Mathf.Atan2(rotateInput.normalized.y, rotateInput.normalized.x) * Mathf.Rad2Deg;
            transform.rotation = Quaternion.Euler(0f, 0f, rot_z);
        }
    }
Beispiel #13
0
    void Update()
    {
        if (characterController.isGrounded)
        {
            // We are grounded, so recalculate
            // move direction directly from axes

            moveDirection  = new Vector3(SimpleInput.GetAxis(horizontalAxis), 0.0f, SimpleInput.GetAxis(verticalAxis));
            moveDirection *= speed;

            if (moveDirection.magnitude > 0)
            {
                transform.rotation = Quaternion.LookRotation(moveDirection);
            }

            if (Input.GetButton("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }
        }

        // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
        // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
        // as an acceleration (ms^-2)
        moveDirection.y -= gravity * Time.deltaTime;

        // Move the controller
        characterController.Move(moveDirection * Time.deltaTime);
    }
Beispiel #14
0
 private void Update()
 {
     // Store the value of both input axes.
     m_MovementInputValue = SimpleInput.GetAxis(m_MovementAxisName);
     m_TurnInputValue     = SimpleInput.GetAxis(m_TurnAxisName);
     EngineAudio();
 }
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        void Update()
        {
            h = SimpleInput.GetAxis("Horizontal");

            if (typeStartus == TypeStartusCar.N || enterPhanh)
            {
                handbrake = 1;
                return;
            }
            else
            {
                handbrake = -1;
            }
            input = CrossPlatformInputManager.GetAxis("Vertical");


            if (CrossPlatformInputManager.GetAxis("Vertical") != 0)
            {
                if (typeStartus == TypeStartusCar.D)
                {
                    input = 1;
                }
                if (typeStartus == TypeStartusCar.R)
                {
                    input = -1;
                }
            }
            else
            {
                input = 0;
            }
        }
Beispiel #16
0
    // Update is called once per frame
    private void Update()
    {
        // if moving // ???

        motion = new Vector3(SimpleInput.GetAxis("Horizontal"), 0, SimpleInput.GetAxis("Vertical"));
        //motion = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));


        if (Mathf.Abs(motion.x) < moveBias &&
            Mathf.Abs(motion.z) < moveBias)
        {
            if (!heroCharacter.targetTracker.IsTracking)
            {
                heroCharacter.StartAttackMode();
            }
        }
        else
        {
            //if(heroCharacter.targetTracker.IsTracking)
            heroCharacter.StopAttackMode();
            motion *= Time.deltaTime;
            heroCharacter.Move(motion);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            heroCharacter.Shoot();
        }
    }
    void Update()
    {
        transform.eulerAngles = new Vector3(0, SimpleInput.GetAxis("Horizontal") * range, 0);

        if (rotator != null)
        {
            rotator.rotation = Quaternion.Euler(0, SimpleInput.GetAxis("Horizontal") * 300, 0);
        }

        if (ShotButton.isPressed || Input.GetKey(KeyCode.Space))
        {
            Handheld.Vibrate();
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit))
            {
                if (hit.transform != null)
                {
                    if (hit.transform.GetComponent <Enemy>() != null)
                    {
                        if (hit.transform.GetComponent <Enemy>().isDead != true)
                        {
                            float damage = PlayerPrefs.GetFloat("distance", 100) * 2;
                            damage = hit.distance / damage;
                            damage = damageByRange.Evaluate(damage) * 100;
                            hit.transform.GetComponent <Enemy>().KillMe(damage);
                        }
                    }
                }
            }
        }
    }
Beispiel #18
0
    //physics in fixed update
    void FixedUpdate()
    {
        //true of false did the ground transform hit the whatIsGround with the groundRadius
        grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);

        //tell the animator that we are grounded
        anim.SetBool("Ground", grounded);

        //get how fast we are moving up or down form the rigidbody
        anim.SetFloat("vSpeed", GetComponent <Rigidbody2D>().velocity.y);

        //get move direction
        float move = SimpleInput.GetAxis("Horizontal");

        // add velocity to the rigidbody in the move direction* ourspeed
        GetComponent <Rigidbody2D>().velocity = new Vector2(move * topSpeed, GetComponent <Rigidbody2D>().velocity.y);

        anim.SetFloat("Speed", Mathf.Abs(move));

        //if we're face the negtive direction and not faceing right , flip
        if (move > 0 && !facingRight)
        {
            Flip();
        }
        else if (move < 0 && facingRight)
        {
            Flip();
        }
    }
Beispiel #19
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //Check for ground
        if (Grounded())
        {
            Vector3 floorNormal = GetFloorNormal();
            //Rolling Noise
            rollPassed += Time.deltaTime;
            if (rollPassed >= rollInterval / rigid.velocity.magnitude)
            {
                rolling.Play();
                rollPassed = 0f;
            }
            // Slow down when no input recieved
            if (SimpleInput.GetAxis("Vertical") == 0.0f && SimpleInput.GetAxis("Horizontal") == 0.0f && rigid.velocity.magnitude > 0.0f)
            {
                rigid.velocity = Vector3.Lerp(rigid.velocity, Vector3.zero, reduceSpeed * 0.1f * Time.deltaTime);
            }

            else
            {
                Vector3 forward      = Vector3.Cross(mainCamera.transform.right, floorNormal);
                Vector3 forwardApply = forward * SimpleInput.GetAxis("Vertical");
                Vector3 rightApply   = SimpleInput.GetAxis("Horizontal") * mainCamera.transform.right;
                //Zoom
                rigid.AddForce((forwardApply + rightApply) * rollSpeed);
            }
        }
    }
Beispiel #20
0
    private void TankUpdate()
    {
        float v = SimpleInput.GetAxis("Vertical");
        float h = SimpleInput.GetAxis("Horizontal");

        bool walk = SimpleInput.GetKey(KeyCode.LeftShift);

        if (v < 0)
        {
            if (walk)
            {
                v *= m_backwardsWalkScale;
            }
            else
            {
                v *= m_backwardRunScale;
            }
        }
        else if (walk)
        {
            v *= m_walkScale;
        }

        m_currentV = Mathf.Lerp(m_currentV, v, Time.deltaTime * m_interpolation);
        m_currentH = Mathf.Lerp(m_currentH, h, Time.deltaTime * m_interpolation);

        transform.position += transform.forward * m_currentV * m_moveSpeed * Time.deltaTime;
        transform.Rotate(0, m_currentH * m_turnSpeed * Time.deltaTime, 0);

        m_animator.SetFloat("MoveSpeed", m_currentV);

        JumpingAndLanding();
    }
Beispiel #21
0
    // Update is called once per frame
    void Update()
    {
        if (MouseEnabled)
        {
            ArmRotation.RotateArmMouse(Input.mousePosition.x, Input.mousePosition.y);

            if (Input.GetButton("Fire1"))
            {
                WeaponShoot.ShootMouse(Input.mousePosition.x, Input.mousePosition.y);
            }
        }
        else
        {
            var vertical   = SimpleInput.GetAxis("Vertical2");
            var horizontal = SimpleInput.GetAxis("Horizontal2");

            if ((vertical == 0) && (horizontal == 0))
            {
                return;
            }

            var direction = new Vector2(horizontal, vertical);
            ArmRotation.RotateArmDirection(direction);
            WeaponShoot.ShootDirection(direction);

            //var verticalButton = SimpleInput.GetButtonDown("Vertical2");
            //var horizontalButton = SimpleInput.GetButtonDown("Horizontal2");

            //if (verticalButton || horizontalButton)
            //{

            //}
        }
    }
Beispiel #22
0
 private void Update()
 {
     if (_timeOfFirePress > 0)
     {
         if (IsFirePressed)
         {
             if (CurrentFireHoldTime >= kMaxFireHoldTime)
             {
                 OnFirePressedEnd();
             }
         }
         else
         {
             OnFirePressedEnd();
         }
     }
     if (Input.anyKey)
     {
         float   inputHorizontal = SimpleInput.GetAxis(HorizontalAxis);
         float   inputVertical   = SimpleInput.GetAxis(verticalAxis);
         Vector2 directional     = new Vector2(inputHorizontal, inputVertical);
         directional = Vector2.ClampMagnitude(directional, 1);
         Move.SafeRaise(directional);
         if (IsFirePressed && _timeOfFirePress == 0)
         {
             //_timeOfFirePress = Time.timeSinceLevelLoad;
             Fire.SafeRaise(GetFireDirection(), 2f);
         }
     }
 }
Beispiel #23
0
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        /* //commented in p5
         * float x = Input.GetAxis("Horizontal");
         * float z = Input.GetAxis("Vertical");
         */

        //new for p5
        float x = SimpleInput.GetAxis("Horizontal");
        float z = SimpleInput.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        //used for 'Jump' method in line19
        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
        }

        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime);
    }
Beispiel #24
0
 void Update()
 {
     if (SimpleInput.GetAxis("Horizontal") != 0 || SimpleInput.GetAxis("Vertical") != 0)
     {
         SendMovementInfo(SimpleInput.GetAxis("Horizontal"), SimpleInput.GetAxis("Vertical"));
         if (Mathf.Abs(SimpleInput.GetAxis("Horizontal")) > 0.85f || Mathf.Abs(SimpleInput.GetAxis("Vertical")) > 0.85f)
         {
             SendBoostInfo(1);
         }
         else
         {
             SendBoostInfo(0);
         }
     }
     if (SimpleInput.GetButton("Fire"))
     {
         SendShootingInfo();
     }
     if (SimpleInput.GetButtonDown("Powerup"))
     {
         SendPowerupInfo();
     }
     //if (SimpleInput.GetButton("Boost"))
     //{
     //    SendBoostInfo(1);
     //} else if (SimpleInput.GetButtonUp("Boost"))
     //{
     //    SendBoostInfo(0);
     //}
 }
Beispiel #25
0
    public void Move()
    {
        _movement              = SimpleInput.GetAxis("Horizontal");
        _rb.velocity           = new Vector2(_movement * _speed, _rb.velocity.y);
        ButtonLeft.localScale  = new Vector2(1.7f, 1.7f);
        ButtonRight.localScale = new Vector2(1.7f, 1.7f);

        if (_movement != 0)
        {
            if (!_currentState.Equals("jump_idle"))
            {
                SetCharacterState("run");
            }

            if (_movement > 0)
            {
                transform.localScale   = new Vector3(0.7f, 0.7f);
                ButtonRight.localScale = new Vector2(1.63f, 1.63f);
                isRotate = 1;
            }
            else
            {
                transform.localScale  = new Vector3(-0.7f, 0.7f);
                ButtonLeft.localScale = new Vector2(1.63f, 1.63f);
                isRotate = -1;
            }
        }
        else
        {
            if (!_currentState.Equals("jump_idle"))
            {
                SetCharacterState("Idle");
            }
        }
    }
Beispiel #26
0
    // Update is called once per fixed time delta
    void FixedUpdate()
    {
        /*
         * This is from Joystic of standard assest
         * var moveRequest = CrossPlatformInputManager.GetAxis("Horizontal");
         * var jumpRequest = CrossPlatformInputManager.GetAxis("Vertical");
         */

        // this is from Joystick from SimpleInput system
        var moveRequest = SimpleInput.GetAxis("Horizontal");
        var jumpRequest = SimpleInput.GetAxis("Vertical");

        if (playerMoveScript != null && playerMoveScript.isActiveAndEnabled)
        {
            playerMoveScript.Move(moveRequest);
        }

        if (playerJumpScript != null && playerJumpScript.isActiveAndEnabled)
        {
            playerJumpScript.Jump(jumpRequest);
        }

        if (playerJetJumpScript != null && playerJetJumpScript.isActiveAndEnabled)
        {
            playerJetJumpScript.Jump(jumpRequest);
        }

        if (playerFlyScript != null && playerFlyScript.isActiveAndEnabled)
        {
            playerFlyScript.Fly(moveRequest, jumpRequest);
        }
    }
Beispiel #27
0
        public void LookRotation(Transform character, Transform camera)
        {
            float yRot = SimpleInput.GetAxis("mouseX") * XSensitivity;
            float xRot = SimpleInput.GetAxis("mouseY") * YSensitivity;

            m_CharacterTargetRot *= Quaternion.Euler(0f, yRot, 0f);
            m_CameraTargetRot    *= Quaternion.Euler(-xRot, 0f, 0f);

            if (clampVerticalRotation)
            {
                m_CameraTargetRot = ClampRotationAroundXAxis(m_CameraTargetRot);
            }

            if (smooth)
            {
                character.localRotation = Quaternion.Slerp(character.localRotation, m_CharacterTargetRot,
                                                           smoothTime * Time.deltaTime);
                camera.localRotation = Quaternion.Slerp(camera.localRotation, m_CameraTargetRot,
                                                        smoothTime * Time.deltaTime);
            }
            else
            {
                character.localRotation = m_CharacterTargetRot;
                camera.localRotation    = m_CameraTargetRot;
            }

            UpdateCursorLock();
        }
    private void Control()
    {
        if (Gamecontroller.TotalLife > 0 && !Gamecontroller.GameEnd)
        {//eixos de movimento
            Movement.x = SimpleInput.GetAxis("Horizontal");
            Movement.z = SimpleInput.GetAxis("Vertical");

            IsGrounded = Physics.CheckSphere(Feet.position, GroundDistance, GroundLayer, QueryTriggerInteraction.Ignore);
            SpeedY     = Body.velocity.y;
            //verifica o input dos botões, para funcionar com controles também
            if (SimpleInput.GetButtonDown("Jump"))
            {
                Jumping();
            }
            if (SimpleInput.GetButtonDown("Fire1"))
            {
                Atacking();
            }
            if (SimpleInput.GetButtonDown("Fire2"))
            {
                Masking();
            }
            if (SimpleInput.GetButtonDown("Fire3"))
            {
                Rescuing();
            }
        }
    }
Beispiel #29
0
        // Fixed update is called in sync with physics
        private void FixedUpdate()
        {
            // read inputs
            float h = SimpleInput.GetAxis("Horizontal");
            float v = SimpleInput.GetAxis("Vertical");

            // calculate move direction to pass to character
            if (m_Cam != null)
            {
                // calculate camera relative direction to move:
                m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
                m_Move       = v * m_CamForward + h * m_Cam.right;
            }
            else
            {
                // we use world-relative directions in the case of no main camera
                m_Move = v * Vector3.forward + h * Vector3.right;
            }
#if !MOBILE_INPUT
            // walk speed multiplier
            if (Input.GetKey(KeyCode.LeftShift))
            {
                m_Move *= 0.5f;
            }
#endif

            // pass all parameters to the character control script
            m_Character.Move(m_Move, m_Jump);
            m_Jump = false;
        }
Beispiel #30
0
 private void Update()
 {
     if (!isAI)
     {
         movement.x = SimpleInput.GetAxis("Horizontal") * Time.fixedDeltaTime * speed;
         movement.y = SimpleInput.GetAxis("Vertical") * Time.fixedDeltaTime * speed;
     }
 }