英文:
I am trying to make a simple dash for my character but there is an issue (i use unity's new input system)
问题
基本上,我正在尝试编写一段代码,当按下时,使 "dashing" 布尔值在 0.2 秒内变为 true,但我无法调用 IEnumerator dash()。(我使用Unity的新输入系统)
public void dash(InputAction.CallbackContext context)
{
if (context.performed)
StartCoroutine("dash");
}
IEnumerator dash()
{
dashing = true;
yield return new WaitForSeconds(0.2f);
dashing = false;
}
英文:
So basically i am trying to do a code that makes "dashing" bool, true for 0.2 sec when pressed. but i cannot call the IEnumerator dash(). (i use unity's new input system)
public void dash(InputAction.CallbackContext context)
{
if (context.performed)
StartCoroutine("dash");
}
IEnumerator dash()
{
dashing = true;
yield return new WaitForSeconds(0.2f);
dashing = false;
}
答案1
得分: 1
只返回翻译好的部分:
"this is not the correct way to call a coroutine, it should do something like this:
StartCoroutine(dash());
Or this:
IEnumerator coroutine = dash();
StartCoroutine(coroutine);
Hope this helps!"
英文:
>StartCoroutine("dash");
this is not the correct way to call a coroutine, it should do something like this:
StartCoroutine(dash());
Or this:
IEnumerator coroutine = dash();
StartCoroutine(coroutine);
Hope this helps!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论