Hi guys, new member / developer and was just wondering if there is a key difference between using the following:
Code 1:
void Update () {
if (Input.GetKey (KeyCode.D)) {
transform.Translate (Vector2.right * speed * Time.deltaTime);
}
if (Input.GetKey (KeyCode.A)) {
transform.Translate (-Vector2.right * speed * Time.deltaTime);
}
Code 2:
void Update ()
{
transform.Translate(Vector2.right * Input.GetAxisRaw(“Horizontal”) * speed * Time.deltaTime);
}
Is it more of a “Organized” thing because i can see how it can be helpful and less time consuming to use GetAxis because its already set up for you in the input manager so it totally cancels out the extra lines of code if you were using Code 1 method.
I would also like to know the difference between GetAxis and GetAxisRaw (I heard the raw was best to use in 2d games, is that true? if so, why?)
P.S.
This will be used for 2d movement along x