実現したいこと
unityでC#を使っていて、エラーの直し方を教えてください。
発生している問題・分からないこと
エラーが発生して実行することができません。
エラーメッセージ
error
1Assets\Scripts\RollingBall.cs(20,30): error CS1513: } expected
該当のソースコード
C#
1using UnityEngine; 2 3public class RollingBall : MonoBehaviour 4{ 5 // 6 private float jumpForce = 5f; 7 // 8 private Rigidbody rigidBody; 9 // 10 private void Awake() 11 { 12 rigidBody = GetComponent<Rigidbody>(); 13 } 14 // 15 // Start is called once before the first execution of Update after the MonoBehaviour is created 16 void Start() 17 { 18 // 19 //GetComponent<Rigidbody>().AddForce(new Vector3(5f, 0f, 0f), 20 ForceMode.Impulse); // 21 } 22 // 23 void FixedUpdate() 24 { 25 if (Input.GetKey(KeyCode.W)) 26 { 27 rigidBody.AddForce(new Vector3(0f, 0f, 5f), ForceMode.Force); 28 } 29 if (Input.GetKey(KeyCode.S)) 30 { 31 rigidBody.AddForce(new Vector3(0f, 0f, -5f), ForceMode.Force); 32 } 33 if (Input.GetKey(KeyCode.D)) 34 { 35 rigidBody.AddForce(new Vector3(5f, 0f, 0f),ForceMode.Force); 36 } 37 if (Input.GetKey(KeyCode.A)) 38 { 39 rigidBody.AddForce(new Vector3(-5f, 0f, 0f), ForceMode.Force); 40 } 41 } 42 // 43 // Update is called once per frame 44 void Update() 45 { 46 // 47 if (Input.GetKeyDown(KeyCode.Space)) 48 { 49 rigidBody.AddForce(new Vector3(0f, jumpForce, 0f), ForceMode. 50 Impulse); 51 } 52 // 53 } 54}
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
自分なりに変更したり調べたりしましたが改善できませんでした。
補足
技術評論社のUnity超入門 やさしくわかるゲーム開発という本を参考にコードを入力しました。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2025/03/26 11:10
2025/03/26 12:13