UnityEngine.Physics.Linecast(UnityEngine.Vector3, UnityEngine.Vector3, int, UnityEngine.QueryTriggerInteraction)

Here are the examples of the csharp api UnityEngine.Physics.Linecast(UnityEngine.Vector3, UnityEngine.Vector3, int, UnityEngine.QueryTriggerInteraction) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : ItemThermalDetonator.cs
License : GNU General Public License v3.0
Project Creator : Kingo64

public void Detonate() {
            var pos = transform.position;
            var colliders = Physics.OverlapSphere(pos, module.radius);
            var damage = new CollisionInstance(new DamageStruct(DamageType.Energy, module.damage), null, null);
            var creatures = new List<Creature>();
            var layerMask = ~((1 << 10) | (1 << 13) | (1 << 26) | (1 << 27) | (1 << 31));
            var creatureMask = ~((1 << 13) | (1 << 26) | (1 << 27) | (1 << 31));

            armedSound.Stop();
            beepTime = 0;

            foreach (var hit in colliders) {
                var distance = Vector3.Distance(hit.transform.position, pos);
                var multiplier = (module.radius - distance) / module.radius;
                var rb = hit.GetComponent<Rigidbody>() ?? hit.GetComponentInParent<Rigidbody>();
                if (rb && (distance < 0.3 || !Physics.Linecast(pos, hit.transform.position, layerMask, QueryTriggerInteraction.Ignore))) {
                    rb.AddExplosionForce(module.impuse * multiplier, pos, module.radius, 1.0f);
                    var creature = hit.transform.GetComponentInParent<Creature>();
                    if (creature) {
                        if (creature != Player.currentCreature) {
                            var rp = hit.GetComponent<RagdollPart>() ?? hit.GetComponentInParent<RagdollPart>();
                            if (rp && rp.sliceAllowed && validParts.ContainsKey(rp.type) && validParts[rp.type] < multiplier) {
                                try {
                                    rp.Slice();
                                }
                                catch { }
                            }
                        }
                        if (!creatures.Contains(creature) && !Physics.Linecast(pos, hit.transform.position, creatureMask, QueryTriggerInteraction.Ignore)) {
                            creatures.Add(creature);
                            damage.damageStruct.damage = module.damage * multiplier;
                            creature.Damage(damage);
                        }
                    }
                }
            }

            Utils.PlaySound(explosionSound, module.explosionSoundreplacedet);
            Utils.PlaySound(explosionSound2, module.explosionSoundreplacedet2);

            Utils.PlayParticleEffect(particles, true);
            renderer.enabled = false;
            item.enabled = false;
            item.Despawn(1.5f);
        }