Проблема -игрок сам прыгает,либо бежит после паузы

Подскажите пожалуйста,как сделать так, чтобы после паузы(Time.TimeScale=0) игрок сам не бежал, либо прыгал.Это происходит после того,как я зажимаю ui кнопку бега либо прыжка и одновременно нажимаю на паузу. Было отличным решением, если после паузы(Time.TimeScale=0) можно было бы сделать : 1)CrossPlatformInputManager.SetAxis("Vertical") =0 2)CrossPlatformInputManager.SetAxis("Horizontal")=0,но к сожалению в интернете по этому поводу я ничего не нашел.

код,который висит на игроке.

public class PlayerController : KinematicObject
{
    public AudioClip jumpAudio;
    public AudioClip respawnAudio;
    public AudioClip ouchAudio;

    /// <summary>
    /// Max horizontal speed of the player.
    /// </summary>
    public float maxSpeed = 7;
    /// <summary>
    /// Initial jump velocity at the start of a jump.
    /// </summary>
    public float jumpTakeOffSpeed = 7;

    public JumpState jumpState = JumpState.Grounded;
    public bool stopJump=true;
    /*internal new*/ public Collider2D collider2d;
    /*internal new*/ public AudioSource audioSource;
    public Health health;
    public bool controlEnabled ;

    bool jump;
    Vector2 move;
    SpriteRenderer spriteRenderer;
    internal Animator animator;
    readonly PlatformerModel model = Simulation.GetModel<PlatformerModel>();

    public Bounds Bounds => collider2d.bounds;

    public Transform spawn1;
    public Transform spawn2;
    public VictoryZone2 VictoryZone2;

    public GameObject text_home;
    public GameObject text_store;
    void Awake()
    {
        int checkPoint = PlayerPrefs.GetInt("CheckPoint");
        switch (checkPoint) {
            case 0:
                this.transform.position = spawn1.position;
                VictoryZone2.Second = false;
                VictoryZone2.Is = false;
                text_home.SetActive(true);
                text_store.SetActive(false);
                break;
            case 1:
                this.transform.position = spawn1.position;
                VictoryZone2.Second = false;
                VictoryZone2.Is = false;
                text_home.SetActive(true);
                text_store.SetActive(false);
                break;
            case 2:
                this.transform.position = spawn2.position;
                VictoryZone2.Is = true;
                VictoryZone2.Second = true;
                text_home.SetActive(false);
                text_store.SetActive(true);
                break;
        }
        health = GetComponent<Health>();
        audioSource = GetComponent<AudioSource>();
        collider2d = GetComponent<Collider2D>();
        spriteRenderer = GetComponent<SpriteRenderer>();
        animator = GetComponent<Animator>();
    }

    protected override void Update()
    {
        if (controlEnabled)
        {
            UnityEngine.Debug.Log(CrossPlatformInputManager.GetAxis("Vertical"));

            move.x = CrossPlatformInputManager.GetAxis("Horizontal");//Input.GetAxis("Horizontal");
            if (jumpState == JumpState.Grounded && CrossPlatformInputManager.GetAxis("Vertical")>0)
            {
                jumpState = JumpState.PrepareToJump;
            }
            else if (CrossPlatformInputManager.GetAxis("Vertical") == 0)//Input.GetButtonUp("Jump")
            {
                stopJump = true;
                Schedule<PlayerStopJump>().player = this;
            }
        }
        else
        {
            move.x = 0;
        }
        UpdateJumpState();
        base.Update();
    }

    void UpdateJumpState()
    {
        jump = false;
        switch (jumpState)
        {
            case JumpState.PrepareToJump:
                jumpState = JumpState.Jumping;
                jump = true;
                stopJump = false;
                break;
            case JumpState.Jumping:
                if (!IsGrounded)
                {
                    Schedule<PlayerJumped>().player = this;
                    jumpState = JumpState.InFlight;
                }
                break;
            case JumpState.InFlight:
                if (IsGrounded)
                {
                    Schedule<PlayerLanded>().player = this;
                    jumpState = JumpState.Landed;
                }
                break;
            case JumpState.Landed:
                jumpState = JumpState.Grounded;
                break;
        }
    }

    protected override void ComputeVelocity()
    {
        if (jump && IsGrounded)
        {
            velocity.y = jumpTakeOffSpeed * model.jumpModifier;
            jump = false;
        }
        else if (stopJump)
        {
            stopJump = false;
            if (velocity.y > 0)
            {
                velocity.y = velocity.y * model.jumpDeceleration;
            }
        }

        if (move.x > 0.01f)
            spriteRenderer.flipX = false;
        else if (move.x < -0.01f)
            spriteRenderer.flipX = true;

        animator.SetBool("grounded", IsGrounded);
        animator.SetFloat("velocityX", Mathf.Abs(velocity.x) / maxSpeed);
        targetVelocity = move * maxSpeed;
    }

    public enum JumpState
    {
        Grounded,
        PrepareToJump,
        Jumping,
        InFlight,
        Landed
    }
}

Ответы (0 шт):