簡體   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