Created
January 21, 2015 01:37
-
-
Save chabiribon/07bf2a61758607328ee5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Jump : MonoBehaviour { | |
public float Jumppower = 3; | |
public LayerMask groundLayer; | |
void Start () { | |
} | |
void Update () { | |
RaycastHit2D hit = Physics2D.Linecast ( | |
transform.position, | |
transform.position - transform.up * 1.2f, | |
groundLayer); | |
if (Input.GetKey (KeyCode.Space) && hit.collider != null) { | |
Vector2 Jump = new Vector2(0,Jumppower); | |
rigidbody2D.velocity = Jump * Jumppower; | |
audio.Play(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment