攻撃アニメーションを作成する
![Cfac7d33 78cf 408c be21 effb77cd13a9](https://codegenius.org/uploads/slide/image/2064/cfac7d33-78cf-408c-be21-effb77cd13a9.jpeg)
攻撃アニメーション
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttack : MonoBehaviour {
private Animator anim;
public AudioClip punchSound;
void Start () {
anim = GetComponent<Animator> ();
}
void Update () {
// Qボタンを押すとパンチ
if (Input.GetKeyDown (KeyCode.Q)) {
anim.SetBool ("Jab", true);
AudioSource.PlayClipAtPoint (punchSound, Camera.main.transform.position);
}
// Eボタンを押すとハイキック
if (Input.GetKeyDown (KeyCode.E)) {
anim.SetBool ("Hikick", true);
}
// Sボタンを押すと回転キック
if (Input.GetKeyDown (KeyCode.S)) {
anim.SetBool ("Spinkick", true);
}
// Zボタンを押すとムーンソルトキック
if (Input.GetKeyDown (KeyCode.Z)) {
anim.SetBool ("SAMK", true);
}
}
}
![E75c0796 8b90 4537 a5a0 97c922c3ace7](https://codegenius.org/uploads/slide/image/2065/e75c0796-8b90-4537-a5a0-97c922c3ace7.jpeg)
![Cfac7d33 78cf 408c be21 effb77cd13a9](https://codegenius.org/uploads/slide/image/2064/cfac7d33-78cf-408c-be21-effb77cd13a9.jpeg)
攻撃アニメーション
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttack : MonoBehaviour {
private Animator anim;
public AudioClip punchSound;
void Start () {
anim = GetComponent<Animator> ();
}
void Update () {
// Qボタンを押すとパンチ
if (Input.GetKeyDown (KeyCode.Q)) {
anim.SetBool ("Jab", true);
AudioSource.PlayClipAtPoint (punchSound, Camera.main.transform.position);
}
// Eボタンを押すとハイキック
if (Input.GetKeyDown (KeyCode.E)) {
anim.SetBool ("Hikick", true);
}
// Sボタンを押すと回転キック
if (Input.GetKeyDown (KeyCode.S)) {
anim.SetBool ("Spinkick", true);
}
// Zボタンを押すとムーンソルトキック
if (Input.GetKeyDown (KeyCode.Z)) {
anim.SetBool ("SAMK", true);
}
}
}
![E75c0796 8b90 4537 a5a0 97c922c3ace7](https://codegenius.org/uploads/slide/image/2065/e75c0796-8b90-4537-a5a0-97c922c3ace7.jpeg)
攻撃アニメーションを作成する