#pragma strict
var maxSpeed:float = 10;
var facingRight:boolean = true;
var anim:Animator;
var grounded: boolean;
var groundCheck:Transform;
var player:Transform;
var groundRadius:float = .2;
var isGround:LayerMask;
var vSpeed:float;
function Start () {
audio.Play();
anim = GetComponent(Animator);
}
function FixedUpdate () {
grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, isGround);
print(“is grounded”);
var move:float = Input.GetAxis(“Horizontal”);
anim.SetFloat(“Speed”, Mathf.Abs(move));
rigidbody2D.velocity = new Vector2(move * maxSpeed, rigidbody2D.velocity.y);
if(move > 0 && !facingRight){
Flip();
}
else if(move < 0 && facingRight){
Flip();
}
if(move <= 0){
anim.SetBool(“Idle”, true);
}
if(move >= .01){
anim.SetBool(“Idle”, false);
}
}
function Update (){
if(grounded && Input.GetKeyDown(“space”)){
rigidbody2D.AddForce(new Vector2(0,800));
anim.Play(“WarriorJump”);
}
}
function Flip() {
facingRight = !facingRight;
var theScale:Vector3 = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}