Skip to content

Instantly share code, notes, and snippets.

@chabiribon
Created January 21, 2015 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chabiribon/07bf2a61758607328ee5 to your computer and use it in GitHub Desktop.
Save chabiribon/07bf2a61758607328ee5 to your computer and use it in GitHub Desktop.
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