Answers for "unity player"

1

player script unity

//Simple 2D:
   private Rigidbody2D RB;
    public float speed = 50f;
   
   
    void Start()
    {      
        RB = GetComponent<Rigidbody2D>();        
    }

    void Update()
    {
        if (Input.GetKey(KeyCode.D))
        {
            RB.AddForce(Vector3.right * speed * Time.deltaTime);
        }
        if (Input.GetKey(KeyCode.A))
        {
            RB.AddForce(Vector3.left * speed * Time.deltaTime);
        }
        if (Input.GetKey(KeyCode.W))
        {
            RB.AddForce(Vector3.up * speed * Time.deltaTime);
        }
        if (Input.GetKey(KeyCode.S))
        {
            RB.AddForce(Vector3.down * speed * Time.deltaTime);
        }       
    }
Posted by: Guest on February-16-2020
0

unity

GMAER BOIII
Posted by: Guest on January-23-2021

Browse Popular Code Answers by Language