Started learning to work in Unity3D on a training video and there was a code in it (which did not work):
if (Input.GetKeyDown(KeyCode.W)) rigidbody.velocity.y = 8; Climbing on the Internet and trying several options it all worked for me, only when I replaced the code with this:
Rigidbody rb = GetComponent<Rigidbody>(); if (Input.GetKeyDown(KeyCode.W)) rb.velocity = new Vector3(0, 8, 0); Why instead, the first option does not work, or option:
Rigidbody rb = GetComponent<Rigidbody>(); if (Input.GetKeyDown(KeyCode.W)) rb.velocity.y = 8;