プログラミング未経験です タイトルは用語とかわからなかったのでどう書けばいいのかわからなかったです
とあるyoutuberさんが解説しているゲームの作り方をまねしてunityを使ってブロック崩しを作ろうとしているのですが、動くボールのスクリプトを書いたものがエラーで動きません。
エラーの内容を下に書きました。
Assets\Ball.cs(15,28): error CS1061: 'Ball' does not contain a definition for 'gameobject' and no accessible extension method 'gameobject' accepting a first argument of type 'Ball' could be found (are you missing a using directive or an assembly reference?)
書いたコード
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ball : MonoBehaviour
{
private Rigidbody2D myRigidbody;
public float speedX = 10; public float speedY = 10; // Start is called before the first frame update void Start() { myRigidbody = this.gameobject.GetComponent<Rigidbody2D>(); Vector2 force = new Vector2(speedX, speedY); myRigidbody.AddForce(force); } // Update is called once per frame void Update() { }
}
どこが間違っているのかどなたか教えていただけませんか
よろしくお願いします
あなたの回答
tips
プレビュー