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

Categories

0 votes
1.3k 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...