Rigidbody2D.velocity Problems.
So i'm making 2D Pong Game and i have an error.
" An instance of type 'UnityEngine.Rigidbody2D' is required to access non static member 'velocity'. "
 #pragma strict
 
 var moveup : KeyCode;
 var movedown : KeyCode;
 var speed : float = 10;
 
 function Update () 
 {
     if (Input.GetKey(moveup))
     {
         Rigidbody2D.velocity.y = speed;                  
     }
     else if (Input.GetKey(movedown))
     {
         Rigidbody2D.velocity.y = speed *-1;                       
     }
 
     else 
     {
         Rigidbody2D.velocity.y = 0;
     }
 
 
 }
 
              Answer by 1430x · Oct 13, 2015 at 04:29 PM
Fixed that. All you need is to replace "Rigidbody2D.velocity.y = speed;" to GetComponent.Rigidbody2D().velocity.y = speed; (Add ">" before and after Rigidbody2D).
i cant understand where to add these ">" braces.please send it cleary. with the code.
!!!!!!!!GetComponent.Rigidbody2D().velocity.y = speed; (Add ">" before and after Rigidbody2D).!!!!!!
the above line is completely not understandable.please send the correct code.
(Add ">" before and after Rigidbody2D).
the code doesn't work. please send it with adding the ">" and i cant understand where to add these braces.
this is plane wrong. you can't change velocity.y just like that. And the syntax is faulty.
 var rb = GetComponent<Rigidbody2D>();
 var vel = rb.velocity;
 vel.y = speed;
 rb.velocity = vel;
 
                 Your answer