Exemplo n.º 1
0
    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;
        }
    }
Exemplo n.º 2
0
    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;
    }