Advertisement
GWibisono

2. How to make a 2D Game - Unity 4.3 Tutorial

Apr 23rd, 2016
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var moveUp : KeyCode;
  4. var moveDown : KeyCode;
  5.  
  6. var speed : float = 10;
  7.  
  8. //
  9. function Update ()
  10. {
  11. var check   =0 ;
  12.     if( Input.GetKey(moveUp) ){
  13.         check=1;
  14. /*      GetComponent.<rigidbody2D>().velocity.y = speed;*/
  15.         GetComponent.<Rigidbody2D>().velocity.y = speed;
  16.     }
  17.    
  18.     if( Input.GetKey(moveDown)){
  19.         check=1;
  20. //      GetComponent.<rigidbody2D>().velocity.y = speed * -1;
  21.         GetComponent.<Rigidbody2D>().velocity.y = speed * -1;
  22.     }
  23.    
  24.     if(check==0){ //else
  25. //      GetComponent.<rigidbody2D>().velocity.y =0;
  26.         GetComponent.<Rigidbody2D>().velocity.y = 0;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement