Guest User

Untitled

a guest
May 27th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using UnityEngine;
  5.  
  6. public class Player : MonoBehaviour {
  7.  
  8. public float moveSpeed;
  9. public float jumpHeight;
  10.  
  11. // Use this for initialization
  12. void Start () {
  13.  
  14. }
  15.  
  16. // Update is called once per frame
  17. void Update () {
  18.  
  19. Rigidbody2D playerBody = GetComponent<Rigidbody2D>();
  20.  
  21. if (Input.GetKeyDown("space")){
  22. print("fired");
  23. //playerBody.velocity = new Vector2(playerBody.velocity.x, jumpHeight);
  24. }
  25.  
  26. if (Input.GetKey(KeyCode.LeftArrow))
  27. {
  28. playerBody.velocity = new Vector2(-moveSpeed, playerBody.velocity.y);
  29. }
  30.  
  31. if (Input.GetKey(KeyCode.RightArrow))
  32. {
  33. playerBody.velocity = new Vector2(moveSpeed, playerBody.velocity.y);
  34. }
  35. }
  36. }
Add Comment
Please, Sign In to add comment