简体   繁体   English

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

[英]CS1002 ; Expected. I have a semicolon

I'm following a Brackeys tutorial on making a first person game.我正在学习制作第一人称游戏的 Brackeys 教程。 And I'm makin the character move script and I'm trying to test but I'm getting error我正在制作角色移动脚本,我正在尝试测试,但出现错误

CS1002: ; CS1002:; expected.预期的。

Heres my code.继承人我的代码。

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;

You are not using dot operator to access the attributes of transform component of the object.您没有使用点运算符来访问对象的变换组件的属性。 In Unity every attribute or method is accessed by dot operator.在 Unity 中,每个属性或方法都由点运算符访问。

You must convert the move variable declaration like this,您必须像这样转换移动变量声明,

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

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

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