Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
four
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
31
Issues
31
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
gadig
four
Commits
5ee3e240
Commit
5ee3e240
authored
Oct 13, 2016
by
Zack Rembisz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added hero movement script
parent
1266fa3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
Assets/script/HeroMobility.cs
Assets/script/HeroMobility.cs
+30
-0
No files found.
Assets/script/HeroMobility.cs
0 → 100644
View file @
5ee3e240
using
UnityEngine
;
using
System.Collections
;
public
class
HeroMobility
:
MonoBehaviour
{
public
float
playerSpeed
=
1f
;
private
Rigidbody2D
playerRB
;
Animator
anim
;
// Use this for initialization
void
Start
()
{
playerRB
=
GetComponent
<
Rigidbody2D
>
();
anim
=
GetComponent
<
Animator
>
();
}
// Update is called once per frame
void
Update
()
{
Vector2
input
=
new
Vector2
(
Input
.
GetAxisRaw
(
"Horizontal"
),
Input
.
GetAxisRaw
(
"Vertical"
));
playerMove
(
input
);
}
void
playerMove
(
Vector2
input
){
//Controls hero movement in all 8 directions
playerRB
.
MovePosition
((
Vector2
)
transform
.
position
+
input
*
playerSpeed
);
}
}
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