addforce2D is not applying negative vector

Hi i’m making a pong game where the ball would randomly move left or right at the start of the game. The script follows:

function Start () {

var randomNumber = Random.Range(0f,1f);

if(randomNumber<=0.5){
rigidbody2D.AddForce(new Vector2(80,10));
}

else{
rigidbody2D.AddForce(new Vector2(-80,-10));
}

the script works fine, and has a 50/50 chance on going into if or else clause, but when it goes through the else clause, the ball doesn’t move left(i.e vector2(-80,10)), but moves right(i.e. vector2(80,10)). i’m following a tutorial for Unity 4.3, but coding in Unity 4.6. Was there any changes during versions?

Hi there! I think your issue is simple, try this code:

function Start () {
 
 var randomNumber = Random.Range(0f,1f);
 
 Vector2 force = new Vector2(80, 10);

 if(randomNumber<=0.5){
 rigidbody2D.AddForce(force);
 }
 
 else{
 rigidbody2D.AddForce(force * -1);
 }