Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created October 5, 2018 07:27
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 nabesi777/fd4861dac9cb2b3c004103d9af511ca0 to your computer and use it in GitHub Desktop.
Save nabesi777/fd4861dac9cb2b3c004103d9af511ca0 to your computer and use it in GitHub Desktop.
BlendTreeTest用 MoveOnly
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BrendTreeTest : MonoBehaviour {
public float speed = 5;  //playerのスピード
private Rigidbody rb;
// Use this for initialization
void Start()
{
rb = GetComponent<Rigidbody>(); //Rigidbodyをrbへ取得
}
// Update is called once per frame
void Update()
{
//Playerの移動
var moveHorizontal = Input.GetAxis("Horizontal");
var moveVertical = Input.GetAxis("Vertical");
var movement = new Vector3(moveHorizontal, 0, moveVertical);
rb.AddForce(movement * speed);
float x = rb.velocity.magnitude; //スピード計測
Animator animator = GetComponent<Animator>(); // Animator コンポーネントを得る
animator.SetFloat("speed",x); // Animator に移動速度のパラメータを渡す
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment