とあるサイトに自機狙い弾のスクリプトが載せられていて、それを丸写ししたのですが、対象の弾のinspecter欄にtargetをアタッチする箇所が出来ません。どうしてでしょうか。また、どうすれば表示されるようになるのでしょうか。教えてください。
###エラー
エラーはありません。
###スクリプト
public float target(GameObject target) {
float x = target.transform.position.x - this.transform.position.x;
float y = target.transform.position.y - this.transform.position.y;
float rad = Mathf.Atan2(y,x);
return rad * Mathf.Rad2Deg;
}
public void moveZ(float z,float speed,Rigidbody2D obj) {
Vector2 move;
move.x = Mathf.Cos(Mathf.Deg2Rad * z);
move.y = Mathf.Sin(Mathf.Deg2Rad * z);
obj.velocity = move * speed;
}
###問題の部分
public float target(GameObject target)
回答1件
あなたの回答
tips
プレビュー