Created
July 1, 2017 15:05
-
-
Save hcosta/9a582e164aa05dc48e61fb905d6a70e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour { | |
public float speed = 4f; | |
Animator anim; | |
void Start () { | |
anim = GetComponent<Animator>(); | |
} | |
void Update () { | |
Vector3 mov = new Vector3( | |
Input.GetAxisRaw("Horizontal"), | |
Input.GetAxisRaw("Vertical"), | |
0 | |
); | |
transform.position = Vector3.MoveTowards( | |
transform.position, | |
transform.position + mov, | |
speed * Time.deltaTime | |
); | |
anim.SetFloat("movX", mov.x); | |
anim.SetFloat("movY", mov.y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment