void LateUpdate() { if (_targetTransform == null) { var go = GameObject.FindGameObjectWithTag(_tag.ToString()); if (go != null) { _targetTransform = go.GetComponent <Transform>(); } return; } var playerPosition = _targetTransform.position; switch (_followType) { case FollowType.None: cachedTransform.position = playerPosition + _offsetFromTargetGameObject; break; case FollowType.Lerp: cachedTransform.position = Vector3.Lerp(cachedTransform.position, playerPosition + _offsetFromTargetGameObject, _timeMultiplier * Time.deltaTime); break; case FollowType.SmoothStep: cachedTransform.position = SmoothStep(cachedTransform.position, playerPosition + _offsetFromTargetGameObject, _timeMultiplier * Time.deltaTime); break; } }
void OnCollisionEnter2D(Collision2D collision) { if (!collision.gameObject.CompareTag(_tag.ToString())) { return; } switch (_rendererType) { case RendererType.Mesh: _meshRenderer.materials = _enable; break; case RendererType.SkinMesh: _skinMeshRenderer.materials = _enable; break; } _fallback = true; }