Skip to content

Instantly share code, notes, and snippets.

@kcha4github
Created August 15, 2018 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kcha4github/e9bc80f4821502ab908dcf501745df60 to your computer and use it in GitHub Desktop.
Save kcha4github/e9bc80f4821502ab908dcf501745df60 to your computer and use it in GitHub Desktop.
Study for Unity that Charactor moving forward and back.
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