Realize the control of character movement and rotation in Unity3D

                How to simply implement keyboard control movement and rotation in Unity

we can use

 The Input Manager method in unity   

The code is implemented as follows  


        float x = Input.GetAxis("Vertical");
        float y = Input.GetAxis("Horizontal");

        //W forward S backward

        gameObject.transform.Translate(Vector3.forward * Time.deltaTime * x);

        //A turns left D turns right
        gameObject.transform.Rotate(0, 90 * Time.deltaTime * y, 0);

Guess you like

Origin blog.csdn.net/Asklyw/article/details/129709515