void Start() { var player = PlayerIndexes.FromArrayIndex(this.playerIndex); mainCameraScript = GameObject.Find("Main Camera").GetComponent <CameraBehaviour>(); #region 当たり判定 opponent = CommonScript.ReverseTeban(player); opponentHitboxTag = ThisSceneDto.HitboxTags[this.Opponent][(int)HitboxIndex.Hitbox]; hitboxsSpriteRenderer = new SpriteRenderer[] { GameObject.Find(ThisSceneDto.HitboxPaths[player][(int)HitboxIndex.Hitbox]).GetComponent <SpriteRenderer>(), GameObject.Find(ThisSceneDto.HitboxPaths[player][(int)HitboxIndex.Weakbox]).GetComponent <SpriteRenderer>(), GameObject.Find(ThisSceneDto.HitboxPaths[player][(int)HitboxIndex.Strongbox]).GetComponent <SpriteRenderer>(), }; weakboxCollider2D = GameObject.Find(ThisSceneDto.HitboxPaths[player][(int)HitboxIndex.Weakbox]).GetComponent <BoxCollider2D>(); #endregion #region ジャンプ groundLayer = LayerMask.GetMask("Ground"); Rigidbody2D = GetComponent <Rigidbody2D>(); animator = GetComponent <Animator>(); #endregion // x位置を共有できるようにするぜ☆ ThisSceneDto.PlayerToTransform[player] = transform; }
void Start() { #region 当たり判定 mainCamera = GameObject.Find("Main Camera"); mainCameraScript = mainCamera.GetComponent <CameraBehaviour>(); #endregion #region 弾作成 // 味方キャラクター のオブジェクトを取得 GameObject friendChar = GameObject.FindWithTag(ThisSceneDto.PlayerToTag[friend]); // 弾のrigidbody2Dコンポーネントを取得 Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>(); // 味方キャラクター の向いている向きに弾を飛ばす rigidbody2D.velocity = new Vector2(speed * friendChar.transform.localScale.x, rigidbody2D.velocity.y); // 弾の画像の向きを 味方キャラクター に合わせる Vector2 temp = transform.localScale; temp.x = friendChar.transform.localScale.x / Common.SCALE; transform.localScale = temp; // 5秒後に消滅 Destroy(gameObject, 5); #endregion }