- 204 名前:名前は開発中のものです。 mailto:sage [2018/08/16(木) 22:44:42.81 ID:Uv2sLsh/.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(translate.up*bulletspeed); } これで弾の後ろはちゃんと自機に向いているのですが何故か角度によって正常に緑矢印方向に進みません…(改行規制に引っ掛かったので少し詰めてます)
|

|