标识符未声明…但我正在声明它现在?

huangapple go评论97阅读模式
英文:

indentifier not declared... but im declaring it now?

问题

func _physics_process(delta):
  climbing()

脚本编辑器显示:
"climbing" 方法未声明,等等...

就像我现在正在声明它一样...你想要什么,Godot?你寻求什么?

我在 func _physics_process(delta) 下声明了几十个东西,然后我尝试实现爬升系统的升级... 突然间,Godot 决定不再让我这样做。

我甚至不知道我做错了什么,因为我一步一步地按照教程操作...

英文:
func _physics_process(delta):
  climbing()

the script editor says:
"the method climbing isn't declared yada yada..

like I'm literally declaring it now...what do you want from godot? what is it that you seek?

I have declared a few dozen things under func _physics_process(delta), then i tried implementing an upgrade for the climbing system... and suddenly godot decided to not let me do it anymore.

I don't even know what am I doing wrong as I'm following a tutorial step by step...

答案1

得分: 1

根据您提供的代码:不,您现在不是在字面上声明 climbing(),您只是在调用它。

您需要:

func _physics_process(delta):
  climbing()

func climbing():
  [在此处放置代码]

如果 climbing 是在其他脚本中声明的,您需要引用附加到脚本的对象,例如,如果 spiderman 是当前节点的子节点,则需要 $spiderman.climbing()

英文:

Based on the code you provided: no, you are not literally declaring climbing() now, you are only calling it.

You need:

func _physics_process(delta):
  climbing()

func climbing():
  [code goes here]

If climbing was declared in some other script, you need to reference the object the script is attached to, eg $spiderman.climbing() if spiderman is a child node of the current node.

huangapple
  • 本文由 发表于 2023年6月15日 06:41:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76478013.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定