What rigidbody2d.velocity.set really does?

Well, i’m doing a Pong 2d tutorial, but the professor is using Javascript and i’m trying to do
in C# (that’s because i already know it a little and for the positive points of the language).

I now that i’m can’t set the velocity of a rigidbody2d, and i found a solution here

But, when i’m trying to resolve that problem i tried to use rigidbody2d.velocity.set and, for use that, my bar (pong character) started and doen’t stop to fall down in the y axis.


EDIT

The player was falling because the gravity was enabled. My mistake (as usually xD).
But, still when i use rigidbody2d.velocity.set(x, y) he actually don’t “set” the velocity and
the player doesn’t moves.


What rigidbody2d.velocity.set do? Shoudn’t act like a setter?

Thank you by now.

Here’s my code:

using UnityEngine;
using System.Collections;

public class PlayerControls : MonoBehaviour
{

		//keys to movement the character
		public KeyCode moveUp;
		public KeyCode moveDown;

		//the character speed
		float speed = 10;
	
		//Update is called once per frame
		void Update ()
		{
				if (Input.GetKey (moveUp)) {

						//the player goes to up
						rigidbody2D.velocity.Set (0, speed);
		
				} else if (Input.GetKey (moveDown)) {

						//the player goes to down//
						rigidbody2D.velocity.Set (0, speed * -1);

		
				} else {

						/*player doen't playing a key. So, don't move!*/
						rigidbody2D.velocity.Set (0, 0);
		
				}
	
		}
}

You are setting it move at a speed of 10. Might possibly be way too fast, try reducing the speed variable value or multiply it all by Time.deltaTime. Other than that I have no idea, it should be acting as a setter indeed, unless something is going on behind the scenes I didn’t read.