(この記事の使用環境: Unity5.4.2f2 Personal、Windows10


今回はアセットの紹介です。

「ファイティングユニティちゃん 無料お試しアセット」。
https://www.assetstore.unity3d.com/jp/#!/content/33478
SnapCrab_NoName_2016-12-30_15-21-57_No-00

動かしてみた。こんな感じ。


Animatorの設定はデフォのまま。こんな感じ。
SnapCrab_NoName_2016-12-30_15-28-24_No-00

スクリプトで、キーボードから動かせるようにしてみた。各アクションをテンキーから。

using UnityEngine;
using System.Collections;

public class KeyBoardController : MonoBehaviour
{

    public float speed;

    float x;
    float z;

    Rigidbody rb;
    Animator anim;

    enum eState
    {
        Idle,
        Run,
    }
    eState _state = eState.Idle;

    void Start ()
    {
        rb = GetComponent<Rigidbody> ();
        anim = GetComponent<Animator> ();
    }

    void FixedUpdate ()
    {

        x = Input.GetAxis ("Horizontal");
        z = Input.GetAxis ("Vertical");

        rb.MovePosition (new Vector3 (
            transform.position.x + x * speed * Time.deltaTime,
            transform.position.y,
            transform.position.z + z * speed * Time.deltaTime));

        if (x != 0 || z != 0)
        {
            _state = eState.Run;
            anim.SetBool ("Run", true);
        }
        else
        {
            _state = eState.Idle;
            anim.SetBool ("Run", false);
        }

        if (Input.GetKeyDown (KeyCode.Keypad1)) anim.SetTrigger ("Jab");
        if (Input.GetKeyDown (KeyCode.Keypad2)) anim.SetTrigger ("Hikick");
        if (Input.GetKeyDown (KeyCode.Keypad3)) anim.SetTrigger ("Spinkick");
        if (Input.GetKeyDown (KeyCode.Keypad4)) anim.SetTrigger ("Rising_P");
        if (Input.GetKeyDown (KeyCode.Keypad5)) anim.SetTrigger ("Headspring");
        if (Input.GetKeyDown (KeyCode.Keypad6)) anim.SetTrigger ("Land");
        if (Input.GetKeyDown (KeyCode.Keypad7)) anim.SetTrigger ("ScrewK");
        if (Input.GetKeyDown (KeyCode.Keypad8)) anim.SetTrigger ("DamageDown");
        if (Input.GetKeyDown (KeyCode.Keypad9)) anim.SetTrigger ("SAMK");
    }
}

今回は以上です。