Skip to content

Instantly share code, notes, and snippets.

@hcosta
Created July 1, 2017 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hcosta/9a582e164aa05dc48e61fb905d6a70e5 to your computer and use it in GitHub Desktop.
Save hcosta/9a582e164aa05dc48e61fb905d6a70e5 to your computer and use it in GitHub Desktop.
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