示例#1
0
    private void Paint(Vector3 loc, Color c)
    {
        RaycastHit hit;

        Vector3 dir = transform.TransformDirection(UnityEngine.Random.onUnitSphere * .1f);

        // Avoid raycast backward as we're in a 2D space
        if (dir.z < 0)
        {
            dir.z = UnityEngine.Random.Range(0f, 1f);
        }

        // Raycast around the position to splash everwhere we can
        int ground = LayerMasker.GetLayerMask(Layers.Ground);
        int blood  = LayerMasker.GetLayerMask(Layers.Blood);

        if (Physics.Raycast(loc, dir, out hit, 1.5f, ground) &&
            Physics.OverlapSphereNonAlloc(hit.point, 0.2f, null, blood) < 3)
        {
            PaintDecal(hit, c);
        }
    }
示例#2
0
    private void EmitDirectionalBlood(DamagePack pack)
    {
        // Determine Position to emit blood from:
        Vector3    position = pack.damaged.owner.position;
        RaycastHit hit;

        if (Physics.Raycast(position, Vector3.down, out hit, 5F, LayerMasker.GetLayerMask(Layers.Ground)))
        {
            position = hit.point;
        }
        else
        {
            // We'll set the 'y' to zero which should be near the floor...
            position.y = 0;
        }

        // Obtain lateral impact direction
        Vector3 impactDir     = pack.damager.impactDirection;
        Vector2 projectileDir = new Vector2(impactDir.x, impactDir.z);

        // Queue Up Blood with the GoreManager
        //GoreManager.Instance.QueueSplat(position, projectileDir);
    }