【3Dゲームエンジン】 ..
206:名前は開発中のものです。
18/08/16 22:55:37.35 1isuZfzA.net
vector3 playerposition; //自機のばしょ
vector3 positiondistance; //弾と自機の座標差から取ったベクトル
float bulletmovedistance; //破壊判定用の動いた距離
[Selializefiled]
float bulletspeed=0.2f; //弾を移動速度
void start()
{
playerposition=GameObject.Find(player).GetCommpoment〈Transform〉.position; //自機座標の取得
positiondistance=(playerposition-transform.position).Nomraized; //弾と自機の座標差からベクトル取得&正規化
transform.Fromtorotation(vector3.down,positiondistance); //弾を後ろ側を自機に向ける
}
void update()
{
Bulletcheck();
}
void fixedupdate()
{
Bulletmove();
}
public void Bulletcheck() //弾の破壊判定
{
if(bulletmovedistance<5)
{
GameObject.Dertory(gameobject);
}
}
public void Bulletmove() //弾の移動
{
transform.translate(tranform.up*bulletspeed);
}
こうでした
>>202 2dなので正面方向はtransform.upなんですよね…
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
2462日前に更新/281 KB
担当:undef