Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using UnityEngine;
- public class Player : MonoBehaviour {
- public float moveSpeed;
- public float jumpHeight;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- Rigidbody2D playerBody = GetComponent<Rigidbody2D>();
- if (Input.GetKeyDown("space")){
- print("fired");
- //playerBody.velocity = new Vector2(playerBody.velocity.x, jumpHeight);
- }
- if (Input.GetKey(KeyCode.LeftArrow))
- {
- playerBody.velocity = new Vector2(-moveSpeed, playerBody.velocity.y);
- }
- if (Input.GetKey(KeyCode.RightArrow))
- {
- playerBody.velocity = new Vector2(moveSpeed, playerBody.velocity.y);
- }
- }
- }
Add Comment
Please, Sign In to add comment