Skip to content

Commit

Permalink
added character running animation
Browse files Browse the repository at this point in the history
  • Loading branch information
iamocram committed Mar 17, 2015
1 parent 3d369fc commit d255124
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Animations.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Animations/playerIdle.anim
Binary file not shown.
8 changes: 8 additions & 0 deletions Animations/playerIdle.anim.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Animations/playerRunning.anim
Binary file not shown.
8 changes: 8 additions & 0 deletions Animations/playerRunning.anim.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Controllers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Controllers/PlayerController.controller
Binary file not shown.
8 changes: 8 additions & 0 deletions Controllers/PlayerController.controller.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Scenes/test.unity
Binary file not shown.
29 changes: 27 additions & 2 deletions Scripts/Characters/movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
using System.Collections;

public class movement : MonoBehaviour {

Animator anim;
GameObject scriptManager;
Component scriptManagerStates;

static public float moving = 0f;
static public float spawnRate = 5f;
static public int spawnChance = 5;

bool facingRight = true;


// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
scriptManager = GameObject.Find ("_ScriptManager");
}

Expand Down Expand Up @@ -47,8 +50,24 @@ void Update ()

}

if (Input.GetAxis ("Horizontal") != 0) {
anim.SetFloat ("Speed", 1);

} else {
anim.SetFloat ("Speed", 0);
}




//Flip logic
if (Input.GetAxis ("Horizontal") > 0 && !facingRight)
flip ();
else if (Input.GetAxis ("Horizontal") < 0 && facingRight)
flip();


//Spawn battles based on movement
if (moving > spawnRate) {
int rand = Random.Range(0,10);
if (rand > spawnChance){
Expand All @@ -59,9 +78,15 @@ void Update ()
moving = 0;
}



}

void flip() {
facingRight = !facingRight;
Vector2 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}

}
Binary file added Sprites/walkSprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions Sprites/walkSprite.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d255124

Please sign in to comment.