Commit 5ee3e240 authored by Zack Rembisz's avatar Zack Rembisz

Added hero movement script

parent 1266fa3f
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);
}
}
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