LoginSignup
0
0

More than 3 years have passed since last update.

質問 Unity C# プレイヤーに向かって弾を発射させたい。※注 初心者です。

Posted at

2Dシューティングゲームでプレイヤーに向かって弾を撃つ敵を作ろうと思い、

public GameObject player;
public float speed;

void Start()
{
    this.transform.LookAt(player); //問題の部分 
}

void Update()
{
    this.transform.Translate(speed, 0f, 0f);
}

と書いたのですが、
cannot convert from GameObject to Transform という旨のコンパイルエラー。

それを見て自分は、public GameObject player;を消して
public Transform player;に書き換えたのですが、
今度はinspectorからドラックアンドドロップしてもpublic transform playerに
playerのゲームオブジェクトを入れることができません。

入れようとしてるのはtransformじゃなくて、
シーンにあるプレイヤーのゲームオブジェクトなんだから、
そりゃそうだという話ですが、、

covert?変換とかってできませんか?どうするべきでしょうか?

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0