Commit ae59fabf authored by Andrew Van Buren's avatar Andrew Van Buren

Added character animation and walk particles.

parent a8059fbf
fileFormatVersion: 2
guid: 403389796c389b14ca61ce9802b971a7
timeCreated: 1477012475
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -5,16 +5,18 @@ public class HeroMobility : MonoBehaviour { ...@@ -5,16 +5,18 @@ public class HeroMobility : MonoBehaviour {
public float playerSpeed = 1f; public float playerSpeed = 1f;
private Rigidbody2D playerRB; private Rigidbody2D playerRB;
Animator anim; Animator anim;
private Vector2 lastPos;
public Vector2 deltaPos;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
playerRB = GetComponent<Rigidbody2D> (); playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> (); anim = GetComponent<Animator> ();
lastPos = playerRB.position;
}
} // Update is called once per frame
void FixedUpdate () {
// Update is called once per frame
void Update () {
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
playerMove (input); playerMove (input);
...@@ -24,7 +26,9 @@ public class HeroMobility : MonoBehaviour { ...@@ -24,7 +26,9 @@ public class HeroMobility : MonoBehaviour {
void playerMove (Vector2 input){ void playerMove (Vector2 input){
//Controls hero movement in all 8 directions //Controls hero movement in all 8 directions
playerRB.MovePosition((Vector2)transform.position + input*playerSpeed); playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed);
deltaPos = playerRB.position - lastPos;
lastPos = playerRB.position;
} }
} }
...@@ -6,14 +6,16 @@ public class PlayerAnimation : MonoBehaviour { ...@@ -6,14 +6,16 @@ public class PlayerAnimation : MonoBehaviour {
private Animator animator; private Animator animator;
private Vector2 lastInput = new Vector2(1, 1); private Vector2 lastInput = new Vector2(1, 1);
private int horizontalDir = 1; private int horizontalDir = 1;
private HeroMobility hm;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
hm = GetComponent<HeroMobility>();
} }
// Update is called once per frame // Update is called once per frame
void Update () { void LateUpdate () {
AminateMovement(); AminateMovement();
} }
...@@ -31,6 +33,7 @@ public class PlayerAnimation : MonoBehaviour { ...@@ -31,6 +33,7 @@ public class PlayerAnimation : MonoBehaviour {
animator.SetFloat("X", Mathf.Abs(lastInput.x)); animator.SetFloat("X", Mathf.Abs(lastInput.x));
animator.SetFloat("Y", lastInput.y); animator.SetFloat("Y", lastInput.y);
animator.SetFloat("DeltaPos", hm.deltaPos.magnitude);
Vector2 scale = transform.localScale; Vector2 scale = transform.localScale;
scale.x = horizontalDir; scale.x = horizontalDir;
transform.localScale = scale; transform.localScale = scale;
......
using UnityEngine;
using System.Collections;
public class WalkParticles : MonoBehaviour {
private ParticleSystem ps;
private ParticleSystem.EmissionModule module;
private HeroMobility hm;
// Use this for initialization
void Start () {
ps = GetComponentInChildren<ParticleSystem>();
module = ps.emission;
hm = GetComponent<HeroMobility>();
}
// Update is called once per frame
void LateUpdate () {
if (hm.deltaPos.sqrMagnitude > 0) {
if (!ps.isPlaying) {
ps.Simulate(0.0f, true, false);
module.enabled = true;
ps.Play();
}
} else {
if (ps.isPlaying) {
module.enabled = false;
ps.Stop();
}
}
}
}
fileFormatVersion: 2
guid: c02d1600d235a814fa07fba8e5b0289f
timeCreated: 1477012137
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9b010c00d0171e54a8171c3b7a309f11
timeCreated: 1477614222
licenseType: Free
TextureImporter:
fileIDToRecycleName:
21300000: GADIG_Kamali_WALKDOWN_v9_0
21300002: GADIG_Kamali_WALKDOWN_v9_1
21300004: GADIG_Kamali_WALKDOWN_v9_2
21300006: GADIG_Kamali_WALKDOWN_v9_3
21300008: GADIG_Kamali_WALKDOWN_v9_4
21300010: GADIG_Kamali_WALKDOWN_v9_5
21300012: GADIG_Kamali_WALKDOWN_v9_6
21300014: GADIG_Kamali_WALKDOWN_v9_7
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 16
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites:
- name: GADIG_Kamali_WALKDOWN_v9_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKDOWN_v9_1
rect:
serializedVersion: 2
x: 16
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKDOWN_v9_2
rect:
serializedVersion: 2
x: 32
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKDOWN_v9_3
rect:
serializedVersion: 2
x: 48
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKDOWN_v9_4
rect:
serializedVersion: 2
x: 64
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKDOWN_v9_5
rect:
serializedVersion: 2
x: 80
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKDOWN_v9_6
rect:
serializedVersion: 2
x: 96
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKDOWN_v9_7
rect:
serializedVersion: 2
x: 112
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2b9a7f44f58787242a0318c229106e99
timeCreated: 1477614230
licenseType: Free
TextureImporter:
fileIDToRecycleName:
21300000: GADIG_Kamali_WALKUP_v5_0
21300002: GADIG_Kamali_WALKUP_v5_1
21300004: GADIG_Kamali_WALKUP_v5_2
21300006: GADIG_Kamali_WALKUP_v5_3
21300008: GADIG_Kamali_WALKUP_v5_4
21300010: GADIG_Kamali_WALKUP_v5_5
21300012: GADIG_Kamali_WALKUP_v5_6
21300014: GADIG_Kamali_WALKUP_v5_7
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 16
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites:
- name: GADIG_Kamali_WALKUP_v5_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKUP_v5_1
rect:
serializedVersion: 2
x: 16
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKUP_v5_2
rect:
serializedVersion: 2
x: 32
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKUP_v5_3
rect:
serializedVersion: 2
x: 48
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKUP_v5_4
rect:
serializedVersion: 2
x: 64
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKUP_v5_5
rect:
serializedVersion: 2
x: 80
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKUP_v5_6
rect:
serializedVersion: 2
x: 96
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALKUP_v5_7
rect:
serializedVersion: 2
x: 112
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3fba717dc7cb39b4498eabf5d357025f
timeCreated: 1477614205
licenseType: Free
TextureImporter:
fileIDToRecycleName:
21300000: GADIG_Kamali_WALK_v15_0
21300002: GADIG_Kamali_WALK_v15_1
21300004: GADIG_Kamali_WALK_v15_2
21300006: GADIG_Kamali_WALK_v15_3
21300008: GADIG_Kamali_WALK_v15_4
21300010: GADIG_Kamali_WALK_v15_5
21300012: GADIG_Kamali_WALK_v15_6
21300014: GADIG_Kamali_WALK_v15_7
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 16
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites:
- name: GADIG_Kamali_WALK_v15_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALK_v15_1
rect:
serializedVersion: 2
x: 16
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALK_v15_2
rect:
serializedVersion: 2
x: 32
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALK_v15_3
rect:
serializedVersion: 2
x: 48
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALK_v15_4
rect:
serializedVersion: 2
x: 64
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALK_v15_5
rect:
serializedVersion: 2
x: 80
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALK_v15_6
rect:
serializedVersion: 2
x: 96
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
- name: GADIG_Kamali_WALK_v15_7
rect:
serializedVersion: 2
x: 112
y: 0
width: 16
height: 16
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e50eef1045910194994476ba6314412f
timeCreated: 1477614265
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0ce8ffb2d8e4de94cbc70d88ef2c8e16
timeCreated: 1477614337
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9d80102a95ce589448280b8cd0543acd
timeCreated: 1477614256
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: bf2ec6fc6fe538b4fb956b844a71b830
timeCreated: 1477614272
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 06102c4709669bc43971949da782722c
timeCreated: 1477614498
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: fd115c284f2f6bc478417069ddfd6e45
timeCreated: 1477614659
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 89bdbcc31067b764dbb3c9903f340b9a
timeCreated: 1477614668
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment