void FixedUpdate() { // 足の位置 var leg = _legList[_legIdx].last; Vector2 pos = _mousePosition; var v = (pos - _body.position); float w = v.magnitude; if (w != 0) { v = v / w * Mathf.Min(w, RADIUS); Vector2 vv = leg.body.position; vv += ((_body.position + v) - vv) * 0.25f; leg.body.position = vv; } // 足を伸ばす if (_isInput) { var hit = Physics2D.Raycast(_body.position, v, 22.0f, LayerMask.GetMask("Map")); if (hit.collider != null) { // 当たった壁に向かって移動 { leg.SetTouch(hit.normal); leg.body.position = hit.point; _legIdx = (_legIdx + 1) % _legList.Count; var next = (_legIdx + 1) % _legList.Count; _legList[_legIdx].last.SetUntouch(); _legList[next].last.SetNextUntouch(); SoundManager.Instance.PlaySE(SEPath._LEG_TOUCH); } // いろんな壁との衝突をここで処理しちゃう { var aa = hit.collider.GetComponentInParent <MoveWall>(); if (aa != null) { leg.SetMoveWall(aa); } } } _isInput = false; } // ダメージ判定 if (_mainController.IsGoal() == false && _mainController.IsDamage() == false) { Vector2 dir = _body.velocity; { // 壁 var hit = Physics2D.CircleCast(_body.prevPosition, DAMAGE_RADIUS, dir, dir.magnitude, LayerMask.GetMask("Map")); if (hit.collider != null) { _mainController.OnPlayerDamage(); _dmgScaleVel = 0.5f; } } { // チェックポイント var hit = Physics2D.CircleCast(_body.prevPosition, DAMAGE_RADIUS, dir, dir.magnitude, LayerMask.GetMask("CheckPoint")); if (hit.collider != null) { _mainController.CheckPoint(hit.collider.transform.position.x); var check = hit.collider.GetComponentInParent <CheckPoint>(); if (check.IsGoal()) { _mainController.Goal(); } } } } // ダメージアニメ { var scl = _face.transform.localScale.x; _dmgScaleVel *= 0.8f; _dmgScaleVel += (1.0f - scl) * 0.25f; scl += _dmgScaleVel; _face.transform.localScale = new Vector3(scl, scl, 1.0f); } }