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
64d16f00
Commit
64d16f00
authored
Nov 19, 2016
by
Andrew Van Buren
Browse files
Fixed footstep glitch
parent
ffeb0fff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Assets/Scripts/HeroMobility.cs
View file @
64d16f00
...
...
@@ -19,8 +19,8 @@ public class HeroMobility : MonoBehaviour {
public
AudioClip
[]
grassFootsteps
;
public
AudioClip
[]
waterFootsteps
;
public
bool
canMove
=
true
;
public
bool
canMove
=
true
;
void
Start
()
{
playerRB
=
GetComponent
<
Rigidbody2D
>
();
...
...
@@ -35,14 +35,14 @@ public class HeroMobility : MonoBehaviour {
playerMove
(
input
);
if
(
deltaPos
.
magnitude
>
0.001f
&&
Time
.
time
>
lastFootstep
)
{
lastFootstep
+
=
footStepDelay
;
lastFootstep
=
Time
.
time
+
footStepDelay
;
Footstep
();
}
}
void
playerMove
(
Vector2
input
){
//Controls hero movement in all 8 directions
if
(
canMove
)
if
(
canMove
)
playerRB
.
MovePosition
((
Vector2
)
transform
.
position
+
input
.
normalized
*
playerSpeed
);
deltaPos
=
playerRB
.
position
-
lastPos
;
lastPos
=
playerRB
.
position
;
...
...
@@ -60,4 +60,4 @@ public class HeroMobility : MonoBehaviour {
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment