Gravity doesn't work

Hello,

I think this line in my script makes the velocity of the rigidbody on the y axis zero, so the gravity doesn’t work. How can I fix this?

rigidbody.velocity = transform.forward * Input.GetAxis("Vertical") * speed * Time.deltaTime;

As far as I know, transform.forward is Vector3(0,0,1). So, all your math affects only z axes.

Yeah, remember the X Y Z sequence, so the (0,0,1) means 0x 0y 1z.
If you’d like the code to affect the Y only, then try something like:

rigidbody.velocity = transform.up * Input.GetAxis("Vertical") * speed * Time.deltaTime;

Or if you want it to affect both Y and Z, then:

var there : Vector3(1,0,1);
rigidbody.velocity = transform.there * Input.GetAxis("Vertical") * speed * Time.deltaTime;