繁体   English   中英

CS1002; 预期的。 我有一个分号

[英]CS1002 ; Expected. I have a semicolon

我正在学习制作第一人称游戏的 Brackeys 教程。 我正在制作角色移动脚本,我正在尝试测试,但出现错误

CS1002:; 预期的。

继承人我的代码。

public CharacterController controller;
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform right * x * transform forward * z;
controller.Move(move);
Vector3 move = transform right * x * transform forward * z;

应该:

Vector3 move = transform.right * x + transform.forward * z;

您没有使用点运算符来访问对象的变换组件的属性。 在 Unity 中,每个属性或方法都由点运算符访问。

您必须像这样转换移动变量声明,

Vector3 move = transform.right * x * transform.forward * z;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM