duck

duck

Jun 17th, 2010
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. public class Player : MonoBehaviour {
  2.  
  3.     float xMove = 0;
  4.     float yMove = 0;
  5.     float gravity = 0.1f;
  6.  
  7.     void FixedUpdate() {
  8.         yMove += gravity;
  9.     }
  10.  
  11.     void Update() {
  12.  
  13.         xMove = Input.GetAxis("Horizontal");
  14.  
  15.         if (onGround && Input.GetKeyDown(KeyCode.Space)) {
  16.             yMove = -5;
  17.         }
  18.  
  19.         transform.Translate(new Vector3(xMove,yMove,0)* Time.deltaTime);
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment