void Update()
{
float h = ETCInput.GetAxis("Horizontal");
float v = ETCInput.GetAxis("Vertical");
if (v > 0)
{
if (h <= 1 && h > 0.75f)
{
Debug.Log(h + " you");
}
else if (h <= 0.75f && h > 0.25f)
{
Debug.Log(h + " youshang");
}
else if (h <= 0.25f && h > -0.25f)
{
Debug.Log(h + " shang");
}
else if (h <= -0.25f && h > -0.75f)
{
Debug.Log(h + " zuoshang");
}
else if (h <= -0.75f && h > -1f)
{
Debug.Log(h + " zuo");
}
}
else if (v < 0)
{
if (h <= 1 && h > 0.75f)
{
Debug.Log(h + " you");
}
else if (h <= 0.75f && h > 0.25f)
{
Debug.Log(h + " youxia");
}
else if (h <= 0.25f && h > -0.25f)
{
Debug.Log(h + " xia");
}
else if (h <= -0.25f && h > -0.75f)
{
Debug.Log(h + " zuoxia");
}
else if (h <= -0.75f && h > -1f)
{
Debug.Log(h + " zuo");
}
}
else
{
if (h > 0)
{
Debug.Log(h + " you");
}
else if (h < 0)
{
Debug.Log(h + " zuo");
}
else
{
Debug.Log("Idle");
}
}
}
EasyTouch 八方向改进--个人学习记录
最新推荐文章于 2019-10-17 15:03:46 发布
本文介绍了一个使用Unity实现的方向输入判断逻辑。通过检测水平和垂直输入轴,该脚本能够根据玩家的不同输入方向,输出相应的Debug日志信息,用于游戏角色的动作控制。
8499

被折叠的 条评论
为什么被折叠?



