void Move()
    {
        if (inVehicule)
        {
            if (joystick.Vertical() != 0)
            {
                a = joystick.Vertical();
            }
            if (joystick.Horizontal() != 0)
            {
                b = joystick.Horizontal();
            }
            //if ((joystick.Horizontal () != 0) && (joystick.Horizontal () != 0)) {
            direction = new Vector2(joystick.Horizontal(), joystick.Vertical());
            //transform.position.x = joystick.Horizontal ();
            //transform.position.y = joystick.Vertical ();
            //tank.transform.position =direction*6f;
            float angle = Mathf.Atan2(a, b) * Mathf.Rad2Deg;
            transform.rotation   = Quaternion.Euler(0, 0, angle + 90f);
            myRigidbody.velocity = direction.normalized * 6f;
            bulletDirection      = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad));



            //}
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (canMove)
        {
            if (!isGravity)
            {
                // Move the object forward along its z axis 1 unit/second.
                this._spaceShip.transform.Translate(Vector3.forward * Time.deltaTime * _speed);

                //Move directional
                if (_Joystick.Horizontal() != 0 || _Joystick.Vertical() != 0)
                {
                    this._spaceShip.transform.Translate(new Vector3((_Joystick.Horizontal() * Time.deltaTime * _speed), (_Joystick.Vertical() * Time.deltaTime * _speed), 0f));
                    this.lossFuel(1);
                }
            }
            else
            {
                Vector3 posShip = this._spaceShip.transform.position;
                if (!stop)
                {
                    if (posShip.x > -3)
                    {
                        this._spaceShip.transform.Translate(Vector3.left * Time.deltaTime * _speed);
                    }
                    else
                    {
                        this._spaceShip.transform.Translate(Vector3.right * Time.deltaTime * _speed);
                    }
                    if (posShip.y > 17)
                    {
                        this._spaceShip.transform.Translate(Vector3.down * Time.deltaTime * _speed);
                    }
                    else
                    {
                        this._spaceShip.transform.Translate(Vector3.up * Time.deltaTime * _speed);
                    }
                    if (posShip.z < 460)
                    {
                        this._spaceShip.transform.Translate(Vector3.forward * Time.deltaTime * _speed);
                    }
                    else
                    {
                        stop = true;
                    }
                }
                else                                             //rotate
                {
                    Vector3 rotationMask = new Vector3(0, 1, 0); //which axes to rotate around
                    this._spaceShip.transform.RotateAround(_planet.transform.position,
                                                           rotationMask, (float)this._speed * Time.deltaTime);
                    if (this._spaceShip.transform.localEulerAngles.y > -90.0f)
                    {
                        this._spaceShip.transform.localEulerAngles = new Vector3(this._spaceShip.transform.localEulerAngles.x, this._spaceShip.transform.localEulerAngles.y - Time.deltaTime * _speed, this._spaceShip.transform.localEulerAngles.z);
                    }
                }
            }
        }
    }
 public void Move()
 {
     isMove = true;
     playerAnimator.SetBool("move", isMove);
     direction.x          = joystick.Horizontal();
     direction.y          = joystick.Vertical();
     myRigidbody.velocity = direction.normalized * walkSpeed;
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        MoveVector = PoolInput();
        Move();

        camera = new Vector3(mainCamera.transform.position.x + (joystick.Horizontal() * cameraSpeed * Time.deltaTime), mainCamera.transform.position.y + (joystick.Vertical() * cameraSpeed * Time.deltaTime), mainCamera.transform.position.z - (joystick.Horizontal() * cameraSpeed * Time.deltaTime));

        mainCamera.transform.position = camera;
    }
    void FixedUpdate()
    {
        if (PlayerPrefs.GetInt("Sr_Type") > 2)
        {
            PlayerPrefs.SetInt("Sr_Type", 0);
        }
        float motor = maxMotorPower * gassSpeed;

        if (PlayerPrefs.GetInt("Sr_Type", 0) == 0)
        {
            float steering = maxSteerAngle * joystick.Horizontal();
            joystick.gameObject.SetActive(true);
            buttons.gameObject.SetActive(false);
            frontLeftWheel.steerAngle  = steering;
            frontRightWheel.steerAngle = steering;
        }

        if (PlayerPrefs.GetInt("Sr_Type") == 1)
        {
            joystick.gameObject.SetActive(false);
            buttons.gameObject.SetActive(false);
            float steering = maxSteerAngle * Input.acceleration.x;
            frontLeftWheel.steerAngle  = steering;
            frontRightWheel.steerAngle = steering;
        }

        if (PlayerPrefs.GetInt("Sr_Type") == 2)
        {
            joystick.gameObject.SetActive(false);
            buttons.gameObject.SetActive(true);
            float steering = maxSteerAngle * steer;
            frontLeftWheel.steerAngle  = steering;
            frontRightWheel.steerAngle = steering;
        }

        backLeftWheel.motorTorque  = motor;
        backRightWheel.motorTorque = motor;

        //Wheel Turning
        TurnWheel(frontLeftWheel);
        TurnWheel(frontRightWheel);
        TurnWheel(backLeftWheel);
        TurnWheel(backRightWheel);

        var rotationVector = transform.rotation.eulerAngles;

        rotationVector.z   = 0;
        transform.rotation = Quaternion.Euler(rotationVector);

        LapText.text = CurrentLap.ToString() + "/" + LapAmount.ToString();
    }
Example #6
0
        // Fixed update is called in sync with physics
        private void FixedUpdate()
        {
            // read inputs
            // float h = CrossPlatformInputManager.GetAxis("Horizontal");
            //float v = CrossPlatformInputManager.GetAxis("Vertical");
            float h      = joystick.Horizontal();
            float v      = joystick.Vertical();
            bool  crouch = Input.GetKey(KeyCode.C);

            // 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, crouch, m_Jump);
            m_Jump = false;
        }
Example #7
0
    private void movement()
    {
        float timer = Time.deltaTime * 4.5f;

        Vector3 velocity = Vector3.zero;
        //MOVEMENT
        float value = (mobile) ? leftJoystick.Vertical() : Input.GetAxis("Vertical");

        value     = value * timer;
        velocity += (Vector3.forward * value);

        value     = (mobile) ? leftJoystick.Horizontal() : Input.GetAxis("Horizontal");
        value     = value * timer;
        velocity += (Vector3.right * value);

        anim.SetFloat("vel", velocity.magnitude);

        velocity      += Physics.gravity * Time.deltaTime / 5;
        velocity       = this.transform.TransformVector(velocity) * 200;
        rigid.velocity = velocity;
        //END OF MOVEMENT
        //CAMERA

        rotBody += ((mobile) ? rightJoystick.Horizontal() : Input.GetAxis("Mouse X")) * 1.5f;
        Quaternion localRotation = Quaternion.Euler(0, rotBody, 0);

        this.transform.localRotation = localRotation;

        rotCamera    += ((mobile) ? -rightJoystick.Vertical() : -Input.GetAxis("Mouse Y")) * 1.5f;
        rotCamera     = Mathf.Clamp(rotCamera, -55, 55);
        localRotation = Quaternion.Euler(rotCamera, 0, 0);
        vista.transform.localRotation = localRotation;

        //END OF CAMERA
    }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        Vector3 movement = new Vector3(joystick.Horizontal(), joystick.Vertical(), 0.0f);

        animator.SetFloat("Horizontal", movement.x);
        animator.SetFloat("Vertical", movement.y);
        animator.SetFloat("Magnitude", movement.magnitude);

        if (movement.x > 0)
        {
            right = true;
        }
        if (movement.x < 0)
        {
            right = false;
        }
        animator.SetBool("Right", right);

        if (!lockMovement)
        {
            transform.position = transform.position + movement * Time.deltaTime;
        }

        if (Input.GetKeyDown("space"))
        {
            throwBottle();
        }
    }
Example #9
0
    void Update()
    {
        inputDirection = Vector3.zero;

        if (!disabledPlayer)
        {
            if (js != null)
            {
                inputDirection = new Vector3(js.Horizontal(), 0, js.Vertical()).normalized;
            }

            else
            {
                inputDirection = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
            }
        }

        inputMagnitude       = inputDirection.magnitude;
        smoothInputMagnitute = Mathf.SmoothDamp(smoothInputMagnitute, inputMagnitude, ref smoothVelocity, smoothTime);

        targetAngle = Mathf.Atan2(inputDirection.x, inputDirection.z) * Mathf.Rad2Deg;

        angle = Mathf.LerpAngle(angle, targetAngle, turnSpeed * Time.deltaTime * inputMagnitude);

        transform.eulerAngles = Vector3.up * angle;
        transform.Translate(transform.forward * moveSpeed * Time.deltaTime * smoothInputMagnitute, Space.World);

        velocity = transform.forward * moveSpeed * smoothInputMagnitute;
    }
 void GetInput()
 {
     forwardInput = joystick.Vertical();
     turnInput    = joystick.Horizontal();
     m_anim.SetFloat("VelX", forwardInput);
     m_anim.SetFloat("VelY", turnInput);
 }
Example #11
0
    void ReadInputAndMove()
    {
        // move closer to destination
        Vector2 p = Vector2.MoveTowards(transform.position, _dest, speed);

        GetComponent <Rigidbody2D>().MovePosition(p);

        // get the next direction from keyboard
        float horizontal = joystick.Horizontal();
        float vertical   = joystick.Vertical();

#if UNITY_STANDALONE || UNITY_WEBPLAYER
        if (Math.Abs(horizontal) > 0 || Math.Abs(vertical) > 0)
        {
#else
        if (Math.Abs(horizontal) > 0.5 || Math.Abs(vertical) > 0.5)
        {
#endif
            if (Math.Abs(horizontal) > Math.Abs(vertical))
            {
                if (horizontal > 0)
                {
                    _nextDir = Vector2.right;
                }
                else
                {
                    _nextDir = Vector2.left;
                }
            }
            else
            {
                if (vertical > 0)
                {
                    _nextDir = Vector2.up;
                }
                else
                {
                    _nextDir = Vector2.down;
                }
            }
        }

        // if pacman is in the center of a tile
        if (Vector2.Distance(_dest, transform.position) < 0.00001f)
        {
            if (Valid(_nextDir))
            {
                _dest = (Vector2)transform.position + _nextDir;
                _dir  = _nextDir;
            }
            else                                                // if next direction is not valid
            {
                if (Valid(_dir))                                // and the prev. direction is valid
                {
                    _dest = (Vector2)transform.position + _dir; // continue on that direction
                }
                // otherwise, do nothing
            }
        }
    }
Example #12
0
    private void Movement()
    {
        Vector3 movement;

        if (Input.GetAxis("Horizontal") > 0 || Input.GetAxis("Vertical") > 0)
        {
            movement = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        }
        else
        {
            movement = new Vector3(joystick.Horizontal(), joystick.Vertical());
        }

        //print(movement);
        //if (movement.x > 0) movement.x = 1;
        //else if (movement.x < 0) movement.x = -1;
        //if (movement.y > 0) movement.y = 1;
        //else if (movement.y < 0) movement.y = -1;

        myBody.velocity = movement * Speed;

        float myBodyPosX = Mathf.Clamp(myBody.position.x, minClampX, maxClampX);
        float myBodyPosY = Mathf.Clamp(myBody.position.y, minClampY, maxClampY);

        myBody.position = new Vector3(myBodyPosX, myBodyPosY);
    }
    private void FixedUpdate()
    {
        float horizontal = vJoystick.Horizontal();

        anim.SetFloat("Speed", Mathf.Abs(horizontal));
        Vector2 currentVelocity = rb2d.velocity;

        if (horizontal * currentVelocity.x < maxSpeed)
        {
            rb2d.AddForce(Vector2.right * horizontal * moveForce);
        }

        if (Mathf.Abs(currentVelocity.x) > maxSpeed)
        {
            rb2d.velocity = new Vector2(Mathf.Sign(currentVelocity.x) * maxSpeed, currentVelocity.y);
        }

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

        if (jump)
        {
            anim.SetTrigger("Jump");
            rb2d.AddForce(new Vector2(0f, jumpForce));
            jump = false;
        }
    }
    void FixedUpdate()
    {
        //good work, keep at it
        if (isMoveable)
        {
            rb.MovePosition(rb.position + (transform.forward * forwardSpeed * Time.fixedDeltaTime));
        }


        /*
         * the standardRot is the rotation the player would have if it were not rotated
         * about its upVector, we need to have this default or else there would be no
         * reference frame for the joystick to rotate off of
         */
        Quaternion standardRot = transform.rotation * ((joystickPos != Vector3.zero) ? Quaternion.Inverse(Quaternion.LookRotation(joystickPos)) : Quaternion.identity);

        //get the x,y position of the joystick
        joystickPos = new Vector3(vJoystick.Horizontal(), 0.0f, vJoystick.Vertical());

        if (joystickPos != Vector3.zero)
        {
            //rotate to the desired orientation
            rb.MoveRotation(standardRot * Quaternion.LookRotation(joystickPos));
        }
    }
Example #15
0
    void Look()
    {
        if (!isPC)
        {
            targetPos    = new Vector3(rightJoystick.Horizontal() + transform.position.x, rightJoystick.Vertical() + transform.position.y);
            transform.up = targetPos - transform.position;
        }
        else
        {
            //Grab the current mouse position on the screen
            Vector3 mousePosition = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z - Camera.main.transform.position.z));

            //Rotates toward the mouse
            transform.eulerAngles = new Vector3(0, 0, Mathf.Atan2((mousePosition.y - transform.position.y), (mousePosition.x - transform.position.x)) * Mathf.Rad2Deg - 90);
        }
    }
Example #16
0
    // Update is called once per frame
    void Update()
    {
        if (this.androidInput)
        {
            this.input.Set(moveJoystick.Horizontal(), moveJoystick.Vertical(), 0);

            //Quaternion eulerRot = Quaternion.Euler(0.0f, 0.0f, lookJoystick.GetComponentInChildren<VirtualJoystick>().transform.position.x);
            //this.transform.rotation = Quaternion.Slerp(transform.rotation, eulerRot, Time.deltaTime * 10);
            //this.transform.Rotate(0f, 0f, -lookJoystick.RotatePlayer() * Time.deltaTime);
            this.transform.eulerAngles = new Vector3(this.transform.eulerAngles.x, 0, Mathf.Atan2(lookJoystick.joystickImg.rectTransform.anchoredPosition.y, lookJoystick.joystickImg.rectTransform.anchoredPosition.x) * Mathf.Rad2Deg - 90);
        }
        else
        {
            this.input.Set(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
            this.playerToMouse      = this.transform.position - this.playerCamera.ScreenToWorldPoint(Input.mousePosition);
            this.playerAngle        = (Mathf.Atan2(this.playerToMouse.x, this.playerToMouse.y) * -Mathf.Rad2Deg) + 180;
            this.transform.rotation = Quaternion.Euler(0, 0, this.playerAngle);
        }

        if (Input.GetKey("backspace"))
        {
            Application.LoadLevel(6);
        }

        UIController.current.PlayerHealthBar(playerHealth);
    }
Example #17
0
    void Update()
    {
        //Initial Movement
        if (!RoughlyEqual(transform.position.z, playerStartPos.z, 0.5f))
        {
            transform.position = Vector3.Lerp(transform.position, playerStartPos, 0.05f);
        }
        else
        {
            allowPlayerMovement = true;
        }

        //Player Movement
        if (allowPlayerMovement)
        {
            float moveHorizontal = joystick.Horizontal();

            rb.velocity = new Vector3(moveHorizontal, 0, 0) * velocity;
            rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -tilt);
            rb.position = new Vector3(Mathf.Clamp(rb.position.x, xMin, xMax), transform.position.y, transform.position.z);
        }

        //Detect Button Press
        if (mouseDown)
        {
            timeMouseDown += Time.deltaTime;
            gun.Shoot();
        }
    }
Example #18
0
    void Update()
    {
        if (characterController.isGrounded)
        {
            // We are grounded, so recalculate
            // move direction directly from axes

            moveDirection  = new Vector3(joystick.Horizontal(), 0.0f, joystick.Vertical());
            moveDirection *= speed;

            if (CrossPlatformInputManager.GetButtonDown("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);

        // Turn the camera
        Turn();
    }
Example #19
0
    private Vector3 MJoystickInput()
    {
        Vector3 dir = Vector3.zero;

        dir.x = Mjoystick.Horizontal();
        dir.y = Mjoystick.Vertical();

        if (dir.magnitude > 1)
        {
            dir.Normalize();
        }
        if (dir.x != 0 && dir.y != 0)
        {
            lewySilnik.Emit(1);
            prawySilnik.Emit(1);

            float angle = Mathf.Atan2(dir.x, dir.y) * Mathf.Rad2Deg;
            transform.rotation = Quaternion.Euler(0, 0, -angle);
        }
        else
        {
            lewySilnik.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
            prawySilnik.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
        }


        return(dir);
    }
    void InputMagnitude()
    {
        //Calculate the input vectors
        inputX = joystick.Horizontal(); // Input.GetAxis("Horizontal");
        inputZ = joystick.Vertical();   //Input.GetAxis("Vertical");

        anim.SetFloat("inputZ", inputZ, 0.0f, Time.deltaTime * 2f);
        anim.SetFloat("inputX", inputX, 0.0f, Time.deltaTime * 2f);

        //Calculate the input magnitude
        speed = new Vector2(inputX, inputZ).sqrMagnitude;

        //Physically move the player
        if (speed >= allowPlayerRotation)
        {
            anim.SetFloat("inputMagnitude", speed, 0f, Time.deltaTime);
            if (inputX != 0 && inputZ != 0)
            {
                PlayerMoveAndRotation();
            }
        }
        else if (speed < allowPlayerRotation)
        {
            anim.SetFloat("inputMagnitude", speed, 0f, Time.deltaTime);
        }
    }
Example #21
0
    void Update()
    {
        if (health <= 0)
        {
            return;
        }

        if (knightCamera.GetComponent <Camera> ().isActiveAndEnabled)
        {
            float translation = joystick.Vertical() * currentSpeed;
            float straffe     = joystick.Horizontal() * currentSpeed;

            translation *= Time.deltaTime;
            straffe     *= Time.deltaTime;

            transform.Translate(straffe, 0, translation);

            if (translation != 0)
            {
                animator.SetBool("isWalking", true);
                animator.SetBool("isIdle", false);
            }
            else
            {
                animator.SetBool("isWalking", false);
                animator.SetBool("isIdle", true);
            }
        }
    }
Example #22
0
    void FixedUpdate()
    {
        bool isBtnClick = heroTransform.isCloudTransform;

        if (isCloud)
        {
            lastPosition = transform.position;
        }

        if (isBtnClick)
        {
            heroTransform.isCloudTransform = false;
            isBtnClick = false;
            isCloud    = !isCloud;
            if (!isCloud)
            {
                Debug.Log("Cloud Disappear!!!!");
                //cloudObject.SetActive (false);
                //Destroy(cloudObject);
                GameManager.Instance.Status = "PlayerSnow";
                transform.position          = outOfScreen;
            }
            else
            {
                Debug.Log("Cloud re-appear!!!!");
                //GameObject cloudObject = GameObject.Find ("CloudBall");
                //cloudObject.SetActive (true);
                GameManager.Instance.Status = "PlayerCloud";
                transform.position          = playerController.lastPosition;
                //GameObject.Instantiate(cloudObject,transform.position/* new Vector3(5.6f,12.5f,0f)*/,Quaternion.identity);
            }
        }

        if (!isCloud)
        {
            transform.position = outOfScreen;
            return;
        }

        //Store the current horizontal input in the float moveHorizontal.
        float moveHorizontal = Input.GetAxis("Horizontal") * speedFactor;

        //Store the current vertical input in the float moveVertical.
        float moveVertical = Input.GetAxis("Vertical") * speedFactor;

        movement = new Vector2(moveHorizontal, moveVertical);

        movement.x = joystick.Horizontal() * speedFactor;

        movement.y = joystick.Vertical() * speedFactor;

        float moveMag = movement.magnitude;

        if (moveMag > MaxSpeed)
        {
            movement = movement * MaxSpeed / moveMag;
        }

        rb2d.velocity = new Vector2(movement.x, movement.y);
    }
Example #23
0
    private void Update()
    {
        currentX -= virtualJoystick.Horizontal() * sensitivityX;
        currentY += virtualJoystick.Vertical() * sensitivityY;

        currentY = ClampAngle(currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
    }
    // Update is called once per frame
    void Update()
    {
        Vector3 dir = Vector3.zero;

        dir.x    = joystick.Horizontal();
        dir.z    = joystick.Vertical();
        rotation = Quaternion.Euler(0, this.transform.eulerAngles.y, 0);
        dir      = rotation * dir;
        if (dir.x != 0 && dir.z != 0)
        {
            WalkF_bool = true;
            //Debug.Log("WTF= =");
            this.transform.Translate(dir.normalized * Time.deltaTime * speed, Space.World);
            qua = Quaternion.LookRotation(dir.normalized);                                                       //※  將Vector3型別轉換四元數型別
            this.transform.rotation = Quaternion.Lerp(this.transform.rotation, qua, Time.deltaTime * smoothing); //四元數的插值,實現平滑過渡
            MainCamera.GetComponent <Transform>().rotation    = Quaternion.Lerp(MainCamera.GetComponent <Transform>().rotation, qua, Time.deltaTime * smoothing);
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);
            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else
        {
            WalkF_bool = false;
        }
        UnityChanSelf.SetBool("WalkF_bool", WalkF_bool);
        //  UnityChanSelf.SetBool("WalkB_bool", WalkB_bool);
        //  UnityChanSelf.SetBool("WalkL_bool", WalkL_bool);
        //  UnityChanSelf.SetBool("WalkR_bool", WalkR_bool);
    }
Example #25
0
    void Update()
    {
        bool walking = true;

        float x = joystick.Horizontal();
        float y = joystick.Vertical();

        Vector3 movement = new Vector3(x, 0, y);

        rb.velocity = movement * speed;

        if (x != 0 || y != 0)
        {
            if (!spiderAudio.isPlaying)
            {
                spiderAudio.Play();
            }

            anim.SetBool("walking", walking);
        }
        else
        {
            if (spiderAudio.isPlaying)
            {
                spiderAudio.Stop();
            }

            walking = false;
            anim.SetBool("walking", walking);
        }
    }
Example #26
0
    }    //move

    private Vector3 GetInput()
    {
        Vector3 direction = Vector3.zero;

        direction.x = joystick.Horizontal();
        direction.y = joystick.Vertical();
        return(direction);
    }    //getInput
Example #27
0
    void Update()
    {
        scoreText.text = "";
        int diff = 10 - score.ToString().Length;

        for (int a = 0; a < diff; ++a)
        {
            scoreText.text += "0";
        }
        scoreText.text += score.ToString();

        if (!Pause.pauseEnabled)
        {
            //Update Movement
            if (movementJoystick.Horizontal() != 0 && movementJoystick.Vertical() != 0)
            {
                movementUpdate();
            }
            else
            {
                AnimationIdleUpdate();
            }

            //Update Velocity
            velocityUpdate();

            //Update Health
            UpdateHealth();

            //Update Shooting
            if (shootingJoystick.Horizontal() != 0 && shootingJoystick.Vertical() != 0)
            {
                //GameObject newBullet = Instantiate(bulletPrefab) as GameObject;
                if (currentTiming < shootingRate)
                {
                    currentTiming += Time.deltaTime;
                }
                else
                {
                    Weapon.ammoCount -= 1;
                    shootingUpdate();
                    currentTiming = 0.0f;
                }
            }
        }
    }
 private void Update()
 {
     dir.x = moveJoystick.Horizontal();
     dir.z = moveJoystick.Vertical();
     if (dir.magnitude > 0)
     {
         wasMoving = true;
     }
 }
Example #29
0
    // Input Check
    void GetInput()
    {
        forwardInput = joystick.Vertical();
        turnInput    = joystick.Horizontal();
        jumpInput    = Input.GetAxisRaw("Jump");

        m_anim.SetFloat("VelX", forwardInput);
        m_anim.SetFloat("VelY", turnInput);
    }
Example #30
0
    void FixedUpdate()
    {
        float moveHorizontal = joystick.Horizontal(); //Input.GetAxis("Horizontal");
        float moveVertical   = joystick.Vertical();   //Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

        rb.AddForce(movement * speed);
    }