Beispiel #1
0
    protected virtual void CreateImpactEffect()
    {
        if (string.IsNullOrEmpty(impactEffect))
        {
            return;
        }

        GameObject loadedEffect = Resources.Load(impactEffect) as GameObject;

        if (loadedEffect == null)
        {
            Debug.LogError("[Projectile] Impact Effect was null");
            return;
        }

        Vector2 dir = parentEffect.Source.transform.position - transform.position;

        float      angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90f;
        Quaternion q     = Quaternion.AngleAxis(angle, Vector3.forward);

        //Quaternion impactRotation = Quaternion.LookRotation(dir, Vector3.forward);

        GameObject activeHitEffect = Instantiate(loadedEffect, transform.position, q) as GameObject;

        VisualEffectManager.SetParticleEffectLayer(activeHitEffect, gameObject);
    }
Beispiel #2
0
    private void CreateHitEffects(RaycastHit2D hit)
    {
        Vector2 rayDir = Vector2.Reflect((hit.point - effectOrigin).normalized, hit.normal);

        Quaternion impactRotation = TargetingUtilities.CalculateImpactRotation(rayDir);

        GameObject hitPrefab = Resources.Load(((EffectAttack)parentEffect).impactEffectName) as GameObject;
        GameObject hitEffect = VisualEffectManager.CreateVisualEffect(hitPrefab, hit.point, impactRotation);


        VisualEffectManager.SetParticleEffectLayer(hitEffect, hit.collider.gameObject);

        //ParticleSystem[] ps = hitEffect.GetComponentsInChildren<ParticleSystem>();
        //SpriteRenderer hitSprite = hit.collider.gameObject.GetComponentInChildren<SpriteRenderer>();

        //for (int i = 0; i < ps.Length; i++) {
        //    ps[i].GetComponent<ParticleSystemRenderer>().sortingOrder = hitSprite.sortingOrder;
        //}
    }