#README Please visit this link to try it out http://goo.gl/QHT6pp You have to have unity web player installed though
Last active
August 29, 2015 14:11
-
-
Save imranismail/ed530ca22d72daeada2d to your computer and use it in GitHub Desktop.
2D Platformer Experimentation in Unity Game Engine. Visit this link to try it out http://goo.gl/QHT6pp
This file contains hidden or 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
#pragma strict | |
var dashButton = "Fire1"; | |
var dashPower : float = 300f; | |
var facingRight : boolean = false; | |
function Start () { | |
} | |
function Update () { | |
if (Input.GetButtonDown(dashButton)) | |
{ | |
var move : float = Input.GetAxis("Horizontal"); | |
if(move > 0) | |
{ | |
rigidbody2D.AddForce(transform.right * dashPower); | |
} | |
else if (move < 0) | |
{ | |
rigidbody2D.AddForce(transform.right * dashPower * -1); | |
} | |
} | |
} |
This file contains hidden or 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
#pragma strict | |
var jumpButton = "Jump"; | |
var jumpPower : float = 650.0f; | |
var animator : Animator; | |
var groundCheck : Transform; | |
var minJumpDelay : float = 0.5f; | |
var jumpTime : float = 0.0f; | |
function Start () { | |
animator = gameObject.GetComponent(Animator); | |
} | |
function Update () { | |
animator.SetBool('Grounded', Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"))); | |
if (jumpTime > 0) | |
{ | |
jumpTime -= Time.deltaTime; | |
} | |
if (Input.GetButtonDown(jumpButton) && animator.GetBool("Grounded")) | |
{ | |
animator.SetBool("Jump", true); | |
rigidbody2D.AddForce(transform.up * jumpPower); | |
jumpTime = minJumpDelay; | |
} | |
if (animator.GetBool('Grounded') && jumpTime <= 0 && animator.GetBool('Jump')) | |
{ | |
animator.SetBool("Jump", false); | |
} |
This file contains hidden or 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
#pragma strict | |
var speed : float; | |
var axisName = "Horizontal"; | |
var anim : Animator; | |
function Start () { | |
} | |
function Awake () { | |
anim = GetComponent(Animator); | |
} | |
function Update () { | |
anim.SetFloat("Speed", Mathf.Abs(Input.GetAxis(axisName))); | |
if (Input.GetAxis(axisName) < 0) | |
{ | |
transform.localScale.x = -1.0f; | |
} | |
else if (Input.GetAxis(axisName) > 0) | |
{ | |
transform.localScale.x = 1.0f; | |
} | |
transform.position += transform.right * Input.GetAxis(axisName) * speed * Time.deltaTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment