Beispiel #1
0
        private void FixedUpdate()
        {
            if (Input.GetKeyDown(KeyCode.R))
            {
                transform.rotation = Quaternion.identity;
                transform.position = originalPosition;
            }

            // pass the input to the car!
            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

                #if !MOBILE_INPUT
            float handbrake = CrossPlatformInputManager.GetAxis("Jump");
            m_Car.Move(h, v, v, handbrake);
                #else
            m_Car.Move(h, v, v, 0f);
                #endif
        }
    public void MoveTowardsClosestTarget()
    {
        if (m_ClosestTargetTransform && CrossPlatformInputManager.GetAxis("Vertical") >= 0f)
        {
            Vector3 direction = (m_ClosestTargetTransform.position - transform.position).normalized;
            m_IsOverridingMouseLook = true;
            // // // rotate to look at
            float distance = Vector3.Distance(m_ClosestTargetTransform.position, transform.position);

            if (distance > m_AutoTargetingStoppingDistance)
            {
                AddImpact(direction, m_AutoTargetingForce);
            }

            StartCoroutine(ResetCameraLook());

            // m_IsOverridingMouseLook = false;
        }
    }
Beispiel #3
0
        private void FixedUpdate()
        {
            // Read the inputs.
            bool crouch = Input.GetKey(KeyCode.S);
            bool hold   = CrossPlatformInputManager.GetButton("Fire3");     //the button for stopping your running and holding in place
            //bool m_Jump = Input.GetKey(KeyCode.W);
            float h = CrossPlatformInputManager.GetAxis("Horizontal");      //horizontal movement axis
            float v = CrossPlatformInputManager.GetAxis("Vertical");        //vertical movement axis (really just used for aiming

            if (h != 0)
            {
                //Debug.Log(h.ToString());
                //Debug.Log(hold.ToString());
            }

            // Pass all parameters to the character control script.
            m_Character.Move(h, v, crouch, m_Jump, hold);
            m_Jump = false;
        }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        float x = CrossPlatformInputManager.GetAxis("Horizontal");
        float y = CrossPlatformInputManager.GetAxis("vertical");

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

        rb.velocity = movement * 4f;

        //if (x != 0 && y != 0)
        while (x != 0 && y != 0)
        {
            transform.eulerAngles = new Vector3(transform.eulerAngles.x, Mathf.Atan2(x, y) * Mathf.Rad2Deg, transform.eulerAngles.z);
            anim.Play("run");
        }
        {
            anim.Play("idle");
        }
    }
Beispiel #5
0
    private void ClimbLadder()
    {
        if (myFeetCollider2D.IsTouchingLayers(LayerMask.GetMask("Climbing")))
        {
            float   controlThrow  = CrossPlatformInputManager.GetAxis("Vertical"); // value is between -1 to  +1
            Vector2 climbVelocity = new Vector2(myRigidBody2D.velocity.x, controlThrow * climbSpeed);
            myRigidBody2D.velocity = climbVelocity;

            bool playerHasVerticalSpeed = Mathf.Abs(myRigidBody2D.velocity.y) > Mathf.Epsilon;
            myAnimator.SetBool("Climbing", playerHasVerticalSpeed);

            myRigidBody2D.gravityScale = 0;
        }
        else
        {
            myAnimator.SetBool("Climbing", false);
            myRigidBody2D.gravityScale = gravityScaleAtStart;
        }
    }
Beispiel #6
0
        private void FixedUpdate()
        {
            if (!isLocalPlayer)
            {
                return;
            }
            //time.text = "Tiempo: "+tiempo.ToString("0.0");
            //tiempo = tiempo - Time.deltaTime;
            // pass the input to the car!
            float h = CrossPlatformInputManager.GetAxis("Horizontal");
            float v = CrossPlatformInputManager.GetAxis("Vertical");

#if !MOBILE_INPUT
            float handbrake = CrossPlatformInputManager.GetAxis("Jump");
            m_Car.Move(h, v, v, handbrake);
#else
            m_Car.Move(h, v, v, 0f);
#endif
        }
    private void GetInput(out float speed)
    {
        // Read input
        float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
        float vertical   = CrossPlatformInputManager.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
        if (!isCrouched)
        {
            m_IsWalking = !CrossPlatformInputManager.GetButton("Run");
        }
#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());
        }

        // Check for pause input
        m_Paused = CrossPlatformInputManager.GetButtonDown("Pause");

        // Check for crouch input
        m_Crouch = CrossPlatformInputManager.GetButtonDown("Crouch");

        ProcessPauseState();
        ProcessCrouch();
    }
Beispiel #8
0
    // 物理引擎中用FixedUpdate代替Update,它的时间固定,不受帧率影响
    private void FixedUpdate()
    {
        if (!currentControl)
        {
            return;
        }

        // 读取输入
        float v      = CrossPlatformInputManager.GetAxis("Vertical");
        bool  crouch = Input.GetKey(KeyCode.C);

        // 计算角色移动的方向
        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;
        }
        else
        {
            // use world-relative directions in the case of no main camera
            m_Move = v * Vector3.forward;
        }

        if (Client.Instance.enterIsland)
        {
            // 将操作参数发送到服务器
            if (m_Move.x != 0 || m_Move.y != 0 || m_Move.z != 0 || crouch != false || m_Jump != false)
            {
                Client.Instance.Manipulate(m_Move, crouch, m_Jump);
            }
        }
        else
        {
            // 将参数传递到CharacterControl脚本
            m_Character.Move(m_Move, crouch, m_Jump);
        }

        m_Jump = false;

        // 更新鼠标锁
        m_MouseLook.UpdateCursorLock();
    }
Beispiel #9
0
    private void ClimbLadder()
    {
        if (!bodyCollider.IsTouchingLayers(LayerMask.GetMask("Climbing")))
        {
            myRigidBody.gravityScale = startingGravity;
            animator.SetBool("IsClimbing", false);
            return;
        }

        float   controlThrow  = CrossPlatformInputManager.GetAxis("Vertical");
        Vector2 climbVelocity = new Vector2(myRigidBody.velocity.x, controlThrow * climbSpeed);

        myRigidBody.gravityScale = 0f;
        myRigidBody.velocity     = climbVelocity;

        bool playerHasVerticalMovement = Mathf.Abs(myRigidBody.velocity.y) > Mathf.Epsilon;

        animator.SetBool("IsClimbing", playerHasVerticalMovement);
    }
Beispiel #10
0
    private void ProcessMovement()
    {
        float xThrow  = CrossPlatformInputManager.GetAxis("Horizontal");
        float xOffset = xThrow * controlSpeed * Time.deltaTime;

        float rawXPos     = transform.localPosition.x + xOffset;
        float clampedXPos = Mathf.Clamp(rawXPos, -xRange, xRange);

        float yThrow  = CrossPlatformInputManager.GetAxis("Vertical");
        float yOffset = yThrow * controlSpeed * Time.deltaTime;

        float rawYPos     = transform.localPosition.y + yOffset;
        float clampedYPos = Mathf.Clamp(rawYPos, -yRange, yRange);

        transform.localPosition = new Vector3(
            clampedXPos,
            clampedYPos,
            transform.localPosition.z);
    }
    //Roate camera method
    void RotateCamera()
    {
        if (target == null)
        {
            return;
        }

        var x = CrossPlatformInputManager.GetAxis("Mouse X");
        var y = CrossPlatformInputManager.GetAxis("Mouse Y");


        m_LookAngle += x * xSpeed;

        m_TiltAngle -= y * ySpeed;

        m_TiltAngle = ClampAngle(m_TiltAngle, yMinLimit, yMaxLimit);

        Quaternion rotation = Quaternion.Euler(m_TiltAngle, m_LookAngle, 0);

        Vector3 targetPos = target.position + new Vector3(0, height, 0);
        Vector3 calPos    = new Vector3(0, 0, -distance);

        transform.rotation = Quaternion.Lerp(transform.rotation, rotation, turnSmoothing * Time.fixedDeltaTime);
        Vector3 position = transform.rotation * calPos + targetPos;

        transform.position = Vector3.Lerp(transform.position, position, Time.time);

        // clip from walls
        if (protectFromWallClip)
        {
            Vector3 dir = (targetPos - transform.position).normalized;
            Vector3 end = targetPos + transform.eulerAngles.y * dir;

            Debug.DrawLine(position, targetPos, Color.red);

            RaycastHit hit;
            if (Physics.Linecast(targetPos, position, out hit, clipLayer))
            {
                //Debug.Log(hit.collider.name);
                transform.position = hit.point;
            }
        }
    }
Beispiel #12
0
 // Update is called once per frame
 void Update()
 {
     if (CrossPlatformInputManager.GetAxis("Vertical") > 0)
     {
         print("w pressed");
     }
     if (CrossPlatformInputManager.GetAxis("Vertical") < 0)
     {
         print("s pressed");
     }
     if (CrossPlatformInputManager.GetAxis("Horizontal") > 0)
     {
         print("d pressed");
     }
     if (CrossPlatformInputManager.GetAxis("Horizontal") < 0)
     {
         print("a pressed");
     }
 }
        private Vector2 GetInput()
        {
            Vector2 input;

            if (!PlayerScript.beStill && !PlayerScript.inBoat)
            {
                input = new Vector2
                {
                    x = CrossPlatformInputManager.GetAxis("Horizontal"),
                    y = CrossPlatformInputManager.GetAxis("Vertical")
                };
            }
            else
            {
                input = new Vector2(0, 0);
            }
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
Beispiel #14
0
        private void GetInput(out float speed)
        {
            // Read input

            float horizontal = 0;

            try {
                horizontal = CrossPlatformInputManager.GetAxis(horizontalAxis);
            }
            catch {
            }
            float vertical = 0;

            try {
                vertical = CrossPlatformInputManager.GetAxis(verticalAxis);
            }
            catch {
            }
            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 #15
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        float h = CrossPlatformInputManager.GetAxis("Horizontal");
        float v = CrossPlatformInputManager.GetAxis("Vertical");

        //transform.Translate(transform.up * speed * v);
        // transform.Translate(transform.right * speed * h);

        if (main_rigidbody.velocity == new Vector2(0, 0))

        {
            anim.SetBool("ismoving", false);
        }

        else
        {
            anim.SetBool("ismoving", true);
        }

        if (facingright)
        {
            main_rigidbody.velocity = new Vector2(h * 4, v * 4);
        }

        else
        {
            main_rigidbody.velocity = new Vector2(h * 4, v * 4);
        }

        if (h > 0 && !facingright)
        {
            flip();
        }
        else if (h < 0 && facingright)
        {
            flip();
        }
    }
	void Update () {
		if ( isCurrentID ) {
			#if UNITY_ANDROID || UNITY_IPHONE
			float axis = CrossPlatformInputManager.GetAxis ( "Zoom" ) ;
			if ( axis != 0 ) {
				posX -= axis * 0.5f ;
				posX = Mathf.Clamp ( posX , 5.0f , 30.0f ) ;
				thisTransform.localPosition = new Vector3 ( posX , thisTransform.localPosition.y , thisTransform.localPosition.z ) ;
			}
			#else
			float axis = Input.GetAxis ( "Mouse ScrollWheel" ) ;
			if ( axis != 0 ) {
				posX -= axis * 10.0f ;
				posX = Mathf.Clamp ( posX , 5.0f , 30.0f ) ;
				thisTransform.localPosition = new Vector3 ( posX , thisTransform.localPosition.y , thisTransform.localPosition.z ) ;
			}
			#endif
		}
	}
Beispiel #17
0
        // Fixed update is called in sync with physics
        private void FixedUpdate()
        {
            // read inputs
            float h      = CrossPlatformInputManager.GetAxis("Horizontal");
            float v      = CrossPlatformInputManager.GetAxis("Vertical");
            bool  crouch = Input.GetKey(KeyCode.C);

            if (crouch)
            {
                if (!crouchSound.isPlaying)
                {
                    crouchSound.Play();
                }
            }

            // 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 *= 1.5f;
                if (!runSound.isPlaying)
                {
                    runSound.Play();
                }
            }
#endif

            // pass all parameters to the character control script
            m_Character.Move(m_Move, crouch, m_Jump);
            m_Jump = false;
        }
Beispiel #18
0
    private void Crouch()
    {
        float controlThrow = CrossPlatformInputManager.GetAxis("Vertical");

        //梯子の上ではしゃがめないのでここで処理を抜ける
        if (myBodyCollider.IsTouchingLayers(LayerMask.GetMask("Ladder")))
        {
            return;
        }
        //梯子の上でなければしゃがみアニメーションにうつる
        if (controlThrow < 0)
        {
            animator.SetBool("Crouch", true);
        }
        if (controlThrow >= 0)
        {
            animator.SetBool("Crouch", false);
        }
    }
Beispiel #19
0
    // Fixed update is called in sync with physics
    private void FixedUpdate()
    {
        // read inputs
        float h = CrossPlatformInputManager.GetAxis("Horizontal");
        float v = CrossPlatformInputManager.GetAxis("Vertical");

        // we use world-relative directions in the case of no main camera
        m_Move = v * Vector3.forward + h * Vector3.right;

        // if grappling, pull the tank towards the grapple
        // doesn't work great
        if (grappleActive && !grapple.GetComponent <GrappleCollisions>().inAir)
        {
            GetComponent <Rigidbody>().AddForce(grapplePullForce * (grapple.transform.position - transform.position).normalized);
        }

        // pass all parameters to the character control script
        m_Character.Move(m_Move);
    }
Beispiel #20
0
    private void Run()
    {
        float controlThrow = CrossPlatformInputManager.GetAxis("Horizontal");

        //移動のスピードを決める
        //ズリバイしている時はスピード遅くなる
        if (Input.GetKey(KeyCode.DownArrow))
        {
            //rigidbody.y 、つまりy方向は物理法則のなすがままにしてあげる
            //一方、xにはズリバイスピードcrowlSpeedをかけて遅くしている
            Vector2 playerVelocity
                = new Vector2(controlThrow * runSpeed * crowlSpeed, myRigidbody.velocity.y);
            myRigidbody.velocity = playerVelocity;
        }
        else //しゃがんでない時
        {
            //rigidbody.y 、つまりy方向は物理法則のなすがままにしてあげる
            Vector2 playerVelocity
                = new Vector2(controlThrow * runSpeed, myRigidbody.velocity.y);
            myRigidbody.velocity = playerVelocity;
        }
        //移動のスピードここまで

        //次にアニメーションや右向き左向きの管理
        if (controlThrow > 0)
        {
            animator.SetBool("Walk", true);
            Flip(-1);//右向き
            lookRight = true;
            lookLeft  = false;
        }
        else if (controlThrow < 0)
        {
            animator.SetBool("Walk", true);
            Flip(1);//左向き
            lookRight = false;
            lookLeft  = true;
        }
        else if (controlThrow <= Mathf.Epsilon)//入力がほぼ0に等しい時
        {
            animator.SetBool("Walk", false);
        }
    }
        private Vector2 GetInput()
        {
            Vector2 input = new Vector2
            {
#if UNITY_ANDROID
                x = dirX,
                y = dirY
#endif
#if UNITY_STANDALONE_WIN
                x = CrossPlatformInputManager.GetAxis("Horizontal"),
                y = CrossPlatformInputManager.GetAxis("Vertical")
#endif
            };

            //dirX = 0;
            //dirY = 0;
            movementSettings.UpdateDesiredTargetSpeed(input);
            return(input);
        }
Beispiel #22
0
    private void FixedUpdate()
    {
        //check both axis for the player movement
        if (Count != 0)
        {
            TimerCounter();
        }

        var vertical   = Input.GetAxis("Vertical");
        var horizontal = Input.GetAxis("Horizontal");
        var movement   = new Vector2(horizontal, vertical);

        rb2d.AddForce(movement * speed);


        Vector2 movement2 = new Vector2(CrossPlatformInputManager.GetAxis("Horizontal"), CrossPlatformInputManager.GetAxis("Vertical")) * 8;

        rb2d.AddForce(movement2);
    }
    private void Movement()
    {
        float move = CrossPlatformInputManager.GetAxis("Horizontal");

        _grounded = IsGrounded();

        Flip(move);

        if (CrossPlatformInputManager.GetButtonDown("B_Button") || Input.GetKeyDown(KeyCode.Space) && IsGrounded())
        {
            _rigid.velocity = new Vector2(_rigid.velocity.x, _jumpForce);
            StartCoroutine(ResetJump());
            _playerAnimation.Jump(true);
        }

        _rigid.velocity = new Vector2(move * _speed, _rigid.velocity.y);

        _playerAnimation.Move(Mathf.Abs(move));
    }
        // Fixed update is called in sync with physics
        private void FixedUpdate()
        {
            // read inputs
            float h = CrossPlatformInputManager.GetAxis("Horizontal");
            // float v = CrossPlatformInputManager.GetAxis("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       = h * m_Cam.right;
                // m_Move = v*m_CamForward + h*m_Cam.right;
            }
            else
            {
                // we use world-relative directions in the case of no main camera
                m_Move = h * Vector3.right;
                // 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
            if (!Main.S.controlScientist)
            {
                m_Move = Vector3.zero;
            }
            m_Character.Move(m_Move, crouch, m_Jump);
            m_Jump = false;

            // Restrict Character to 2D movement
            Vector3 pos = transform.position;
            pos.z = 0;
            transform.position = pos;
        }
Beispiel #25
0
 private void flipControl()
 {
     if(CrossPlatformInputManager.GetAxis("Horizontal") > 0 || Input.GetKeyDown(RIGHT))
     {
         if (FACING != DIRECTION.RIGHT)
         {
             FACING = DIRECTION.RIGHT;
             flip();
         }
     }
     if (CrossPlatformInputManager.GetAxis("Horizontal") < 0 || Input.GetKeyDown(LEFT))
     {
         if (FACING != DIRECTION.LEFT)
         {
             FACING = DIRECTION.LEFT;
             flip();
         }
     }
 }
Beispiel #26
0
    private void ClimbLadder()
    {
        if (!feetCollider.IsTouchingLayers(LayerMask.GetMask("Climbing")))
        {
            animator.SetBool("willClimb", false);
            rigidbody.gravityScale = gravityScale;
            return;
        }

        float   controlFlow = CrossPlatformInputManager.GetAxis("Vertical");
        Vector2 velocity    = new Vector2(rigidbody.velocity.x, controlFlow * climbSpeed);

        rigidbody.velocity     = velocity;
        rigidbody.gravityScale = 0f;

        bool playerHasVerticalVelocity = Mathf.Abs(rigidbody.velocity.y) > Mathf.Epsilon;

        animator.SetBool("willClimb", playerHasVerticalVelocity);
    }
Beispiel #27
0
    private void ClimbLadder()
    {
        if (!myFeet.IsTouchingLayers(LayerMask.GetMask("Climbing")))
        {
            myAnimator.SetBool("Climbing", false);
            myRigidBody.gravityScale = gravityScaleAtStart;
            return;
        }

        float   controlThrow  = CrossPlatformInputManager.GetAxis("Vertical");
        Vector2 climbVelocity = new Vector2(myRigidBody.velocity.x, controlThrow * climbSpeed);

        myRigidBody.velocity     = climbVelocity;
        myRigidBody.gravityScale = 0f;

        bool playerHasVerticalSpeed = Mathf.Abs(myRigidBody.velocity.y) > Mathf.Epsilon;

        myAnimator.SetBool("Climbing", playerHasVerticalSpeed);
    }
 void CheckKeyboardInputs()
 {
     dirX = CrossPlatformInputManager.GetAxis("Horizontal");
     if (dirX < 0)
     {
         if (attached)
         {
             rb.velocity = new Vector2(dirX * Ropespeed, rb.velocity.y);
         }
         else
         {
             rb.velocity = new Vector2(dirX * Groundspeed, rb.velocity.y);
         }
     }
     if (dirX > 0)
     {
         if (attached)
         {
             rb.velocity = new Vector2(dirX * Ropespeed, rb.velocity.y);
         }
         else
         {
             rb.velocity = new Vector2(dirX * Groundspeed, rb.velocity.y);
         }
     }
     if (CrossPlatformInputManager.GetButtonDown("SlideUp") && attached)
     {
         Slide(1);
     }
     if (CrossPlatformInputManager.GetButtonDown("SlideDown") && attached)
     {
         Slide(-1);
     }
     if (CrossPlatformInputManager.GetButtonDown("Jump") && attached)
     {
         rb.AddForce(Vector2.up * RopeJumpForce);
         Detach();
     }
     if (CrossPlatformInputManager.GetButtonDown("Jump") && !attached && isGrounded)
     {
         rb.AddForce(Vector2.up * GroundJumpForce);
     }
 }
    private void FixedUpdate()
    {
        accel = rb.velocity - vel;
        vel   = rb.velocity;

        if (userInputs)
        {
            // pass the input to the car!
            float h         = CrossPlatformInputManager.GetAxis("Horizontal");
            float v         = CrossPlatformInputManager.GetAxis("Vertical");
            float handbrake = CrossPlatformInputManager.GetAxis("Jump");
            RequestSteering(h * MaximumSteerAngle);
            RequestThrottle(v);
            RequestFootBrake(v);
            RequestHandBrake(handbrake);
        }

        unityCar.Move(steering / MaximumSteerAngle, throttle, footBrake, handBrake);
    }
Beispiel #30
0
    private void Move()
    {
        float   controlThrow  = CrossPlatformInputManager.GetAxis("HorizontalTrain"); // value is between -1 to +1
        Vector2 TrainVelocity = new Vector2(controlThrow * moveSpeed, myRigidBody.velocity.y);

        myRigidBody.velocity = TrainVelocity;

        bool TrainHasHorizontalSpeed = Mathf.Abs(myRigidBody.velocity.x) > Mathf.Epsilon;

        myAnimator.SetBool("isDriving", TrainHasHorizontalSpeed);
        if ((Input.GetKey(KeyCode.A)) || (Input.GetKey(KeyCode.D)))
        {
            GetComponent <AudioSource>().UnPause();
        }
        else
        {
            GetComponent <AudioSource>().Pause();
        }
    }