Created
August 15, 2018 01:57
-
-
Save kcha4github/e9bc80f4821502ab908dcf501745df60 to your computer and use it in GitHub Desktop.
Study for Unity that Charactor moving forward and back.
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 UnityChan : MonoBehaviour { | |
public float speed = 1f; | |
Animator animator; | |
// Use this for initialization | |
void Start () { | |
animator = GetComponent<Animator>(); | |
} | |
// Update is called once per frame | |
void Update () { | |
float h = Input.GetAxis("Horizontal"); | |
animator.SetFloat("Speed", h); | |
// Vector3 v = Vector3.right * Time.deltaTime * h * speed; | |
Vector3 v = Vector3.forward * Time.deltaTime * h * speed; | |
transform.Translate(v); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment