teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コピペミスをしていました。GetComponent<Rigidbody>→GetComponent<Rigidbody>()

2021/12/28 05:45

投稿

t_n_k
t_n_k

スコア4

title CHANGED
File without changes
body CHANGED
@@ -6,13 +6,13 @@
6
6
  3Dの「Rigidbody」では、以下の書き方でオブジェクトの動きを止められると思います。
7
7
 
8
8
  ```C#
9
- player.GetComponent<Rigidbody>.velocity = Vector3.zero;
9
+ player.GetComponent<Rigidbody>().velocity = Vector3.zero;
10
10
  ```
11
11
 
12
12
  2Dを使用する場合も、同じやり方でできると思い、以下の書き方で試しましたが、うまくいきませんでした。
13
13
 
14
14
  ```C#
15
- player.GetComponent<Rigidbody2D>.velocity = Vector3.zero;
15
+ player.GetComponent<Rigidbody2D>().velocity = Vector3.zero;
16
16
  //(playerオブジェクトにRigidbody2Dをアタッチしております)
17
17
  ```
18
18