2ちゃんねる ■掲示板に戻る■ 全部 1- 最新50    

■ このスレッドは過去ログ倉庫に格納されています

Unity5質問スレ

35 :名前は開発中のものです。:2015/08/05(水) 23:24:16.52 ID:Wak/H5zk.net
Unity5.1.2の質問です。TPSを作ろうとしていて、弾丸を発射出来ずに困っています。
using UnityEngine;
using System.Collections;

public class GatlingFire : MonoBehaviour {

public GameObject bulletprefab;
public float interval = 0.5f;
public float speed = 1000.0f;

private float nextFire = 0.0f;
private GameObject bullet;

void Update(){
if (Input.GetKey ("t") && Time.time > nextFire) {
nextFire = Time.time + interval;

bullet = Instantiate (bulletprefab, GameObject.Find ("Spawn").transform.position, Quaternion.identity);
bullet.GetComponent<Rigidbody>().velocity = Vector3.forward * speed;
}
}
}

というコードを書いたのですが、
Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
というエラーが出ます。ググってみたのですが、記述に問題はなさそうなんですが、どこかおかしいでしょうか?
どなたかわかる方よろしくお願いします。

総レス数 1002
304 KB
新着レスの表示

掲示板に戻る 全部 前100 次100 最新50
read.cgi ver.24052200