Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

unity3d - Unity Platformer - My character velocity is 4.8 with my character not moving, why?

My player velocity(X), stays in 4.8 even with my character not moving, it has never been an issue, and i just found out about it because a mechanic im trying to do wasnt working and i serialized my velocity and saw that the serialized velocity pic

when i start the game, the X velocity is set to 4.8, the character stays still like is supposed to, the player controller works fine, but i think thats whats making another mechanics now dont work properly. Why is that happening?

Thats my movement method, is called on "Horizontal" Input, so the X was supossed to be 0 when im not moving. Again, the character is not moving by itself, the movement works fine, but the X is set to 4.8 somehow.

void MoveCharacter()
    {

        if (_horizontalInput != 0 && _playerContraints.IsGrounded() == true)
        {
            _animator.SetBool("isWalking", true);
        }
        else
        {
            _animator.SetBool("isWalking", false);
        }


        playerRigidbody2D.velocity = new Vector2(_horizontalInput * _moveSpeed, playerRigidbody2D.velocity.y);


    }
question from:https://stackoverflow.com/questions/65850655/unity-platformer-my-character-velocity-is-4-8-with-my-character-not-moving-wh

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...