Answers for "how to make a simple character controller in unity"

C#
1

how to make a simple character controller in unity

public float speed;

    private Rigidbody2D rb2d;

    void Start()
    {
        rb2d = GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");
        Vector2 movement = new Vector2(moveHorizontal, moveVertical);

        rb2d.AddForce(movement * speed);
    }
}
//make sure to attach a rigidbody to the character, and you can mess around with it
Posted by: Guest on February-23-2021

Code answers related to "how to make a simple character controller in unity"

C# Answers by Framework

Browse Popular Code Answers by Language