using UnityEngine;
using System.Collections;
public class HeroColtrol : MonoBehaviour
{
private Rigidbody2D HeroRd;
public float MoveSpeed;
public float JumpHeight;
void Awake()
{
HeroRd = transform.GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
float h = Input.GetAxis("Horizontal");
if (!h.Equals(0))
{
HeroRd.velocity = new Vector2(h * MoveSpeed, HeroRd.velocity.y);
}
if (Input.GetKeyDown(KeyCode.Space))
{
if (HeroRd.velocity.y.Equals(0))
HeroRd.velocity = new Vector2(HeroRd.velocity.x, JumpHeight);
}
}
}