ソースコードテスト

未分類
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using InControl;
public class ReimuRot : MonoBehaviour {
public tk2dSpriteAnimator animator;
// Update is called once per frame
void Update () {
var ad = InputManager.ActiveDevice;
float angle =  Mathf.Atan2( ad.LeftStick.Y,ad.LeftStick.X);
float angledeg = angle * Mathf.Rad2Deg + 180f;
if(angledeg > 337.5f || angledeg < 22.5f ){
animator.Play("walk_Left");
}
else if(angledeg >= 22.5f && angledeg <= 67.5f ){
animator.Play("walk_ButtomLeft");
}
else if(angledeg >= 67.5f && angledeg <= 112.5f ){
animator.Play("walk_Buttom");
}
else if(angledeg >= 112.5f && angledeg <= 157.5f ){
animator.Play("walk_ButtomRight");
}
else if(angledeg >= 157.5f && angledeg <= 202.5f ){
animator.Play("walk_Right");
}
else if(angledeg >= 202.5f && angledeg <= 247.5f ){
animator.Play("walk_UpperRight");
}
else if(angledeg >= 247.5f && angledeg <= 292.5f ){
animator.Play("walk_Upper");
}
else if(angledeg >= 292.5f && angledeg <= 337.5f ){
animator.Play("walk_UpperLeft");
}
}
}