Created
October 5, 2018 07:27
-
-
Save nabesi777/fd4861dac9cb2b3c004103d9af511ca0 to your computer and use it in GitHub Desktop.
BlendTreeTest用 MoveOnly
This file contains hidden or 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 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