質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Q&A

解決済

1回答

768閲覧

UnityでC#のCS1061エラーが解決出来ない

Rondon7251

総合スコア89

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

0グッド

0クリップ

投稿2023/01/25 07:14

C#

1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class Player : MonoBehaviour 6{ 7 private Rigidbody2D myRigidBody; 8 9 public float playerSpeed = 10; 10 // Start is called before the first frame update 11 void Start() 12 { 13 myRigidBody = this.gameObject.GetComponent<Rigidbody2D>(); 14 } 15 16 // Update is called once per frame 17 void FixedUpdate() 18 { 19 Vector2 force = Vector2.zero; 20 21 if (Input.GetKey(KeyCode.LeftArrow)) 22 { 23 force = new Vector2(playerSpeed * -1, 0); 24 } 25 26 if (Input.GetKey(KeyCode.RightArrow)) 27 { 28 force = new Vector2(playerSpeed, 0); 29 } 30 myRigidBody.Moveposition(myRigidBody.position + force * Time.fixedDeltaTime); 31 } 32} 33

エラー内容
Assets/Player.cs(30,21): error CS1061: 'Rigidbody2D' does not contain a definition for 'Moveposition' and no accessible extension method 'Moveposition' accepting a first argument of type 'Rigidbody2D' could be found (are you missing a using directive or an assembly reference?)

どこか構文が間違ってると思うんですがどこがエラーかわからないためわかる方いましたら教えてください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

typoです。
×Moveposition→○MovePosition

投稿2023/01/25 07:17

fiveHundred

総合スコア9803

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Rondon7251

2023/01/25 08:55

ありがとうございます
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問