【问题标题】:Unity 'Transform does not contain a definition for Position' [closed]Unity'变换不包含位置的定义'[关闭]
【发布时间】:2021-04-17 14:16:35
【问题描述】:

Unity报错,这里是我使用的代码:

void MoveCharacter()
{
    myRigidBody.MovePosition(
        transform.Position + change * speed * Time.deltatime
    );
}

}

【问题讨论】:

标签: c# unity3d position transform


【解决方案1】:

C# 是一种区分大小写的编程语言。 你写的是 transform.Position 而不是 transform.position。

您还尝试对无效的 transform.position 进行操作。 如果要对该位置进行操作,则必须声明 x 或 y。 所以,transform.position.x + 5 是有效的,但是,transform.position + 5 是无效的。

【讨论】:

    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 2022-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多