Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gadig
four
Commits
ae59fabf
Commit
ae59fabf
authored
Oct 27, 2016
by
Andrew Van Buren
Browse files
Added character animation and walk particles.
parent
a8059fbf
Changes
35
Hide whitespace changes
Inline
Side-by-side
Assets/prefabs/Player.prefab
0 → 100644
View file @
ae59fabf
File added
Assets/prefabs/Player.prefab.meta
0 → 100644
View file @
ae59fabf
fileFormatVersion: 2
guid: 403389796c389b14ca61ce9802b971a7
timeCreated: 1477012475
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Assets/scene/player_animation_test.unity
View file @
ae59fabf
No preview for this file type
Assets/script/HeroMobility.cs
View file @
ae59fabf
...
@@ -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
;
}
}
}
}
Assets/script/PlayerAnimation.cs
View file @
ae59fabf
...
@@ -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
Late
Update
()
{
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
;
...
...
Assets/script/WalkParticles.cs
0 → 100644
View file @
ae59fabf
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
();
}
}
}
}
Assets/script/WalkParticles.cs.meta
0 → 100644
View file @
ae59fabf
fileFormatVersion: 2
guid: c02d1600d235a814fa07fba8e5b0289f
timeCreated: 1477012137
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/sprite/GADIG_Kamali_WALKDOWN_v9.png
0 → 100644
View file @
ae59fabf
1.14 KB
Assets/sprite/GADIG_Kamali_WALKDOWN_v9.png.meta
0 → 100644
View file @
ae59fabf
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:
Assets/sprite/GADIG_Kamali_WALKUP_v5.png
0 → 100644
View file @
ae59fabf
797 Bytes
Assets/sprite/GADIG_Kamali_WALKUP_v5.png.meta
0 → 100644
View file @
ae59fabf
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:
Assets/sprite/GADIG_Kamali_WALK_v15.png
0 → 100644
View file @
ae59fabf
1.06 KB
Assets/sprite/GADIG_Kamali_WALK_v15.png.meta
0 → 100644
View file @
ae59fabf
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:
Assets/sprite/animation/Player/GADIG_Kamali_WALKDOWN_v9_0.controller
0 → 100644
View file @
ae59fabf
File added
Assets/sprite/animation/Player/GADIG_Kamali_WALKDOWN_v9_0.controller.meta
0 → 100644
View file @
ae59fabf
fileFormatVersion: 2
guid: e50eef1045910194994476ba6314412f
timeCreated: 1477614265
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Assets/sprite/animation/Player/GADIG_Kamali_WALKUP_v5_0.controller
0 → 100644
View file @
ae59fabf
File added
Assets/sprite/animation/Player/GADIG_Kamali_WALKUP_v5_0.controller.meta
0 → 100644
View file @
ae59fabf
fileFormatVersion: 2
guid: 0ce8ffb2d8e4de94cbc70d88ef2c8e16
timeCreated: 1477614337
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName: