当前位置: 首页>>代码示例>>C#>>正文


C# Rigidbody.AddExplosionForce方法代码示例

本文整理汇总了C#中UnityEngine.Rigidbody.AddExplosionForce方法的典型用法代码示例。如果您正苦于以下问题:C# Rigidbody.AddExplosionForce方法的具体用法?C# Rigidbody.AddExplosionForce怎么用?C# Rigidbody.AddExplosionForce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Rigidbody的用法示例。


在下文中一共展示了Rigidbody.AddExplosionForce方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Awake

    void Awake()
    {
        //If it has Children also turn children into Debris (Used for sails and bigger objects)
        if (transform.childCount > 0)
        {
            for (int i = 0; i < transform.childCount; i++)
            {
                if (transform.GetChild(i).name == "Small")
                {
                    smallChildren.Add(transform.GetChild(i));
                }
            }
            foreach (Transform child in smallChildren)
            {
                child.gameObject.AddComponent<SmallDebrisScript>();
            }
        }

        if (GetComponent<Rigidbody>() == null)
        {
            debrisBody = gameObject.AddComponent<Rigidbody>();
        }
        debrisBody = gameObject.GetComponent<Rigidbody>();
        debrisBody.useGravity = true;
        debrisBody.isKinematic = false;
        //debrisBody.AddForce(((transform.up + transform.position) * 2) * debrisBody.mass);
        debrisBody.AddExplosionForce(250, transform.position, 50, 25);
        transform.parent = null;
        name = "Debris";
        Destroy(this);
    }
开发者ID:Ohmu93,项目名称:PirateShipsProject,代码行数:31,代码来源:DebrisScript.cs

示例2: OnCollisionEnter

    void OnCollisionEnter(Collision collision)
    {
        // 		Debug.Log(collision.gameObject.transform.name);
        rigidbody = collision.gameObject.GetComponent<Rigidbody>();

        audio.PlayOneShot(effect_sound);

        rigidbody.AddExplosionForce(power, collision.gameObject.transform.position, radius);

        PlayerControl.ComboCount += 1;
        PlayerControl.Count += 1;
        if(PlayerControl.ComboCount >= 3)
        {
            if(PlayerControl.Rezentime <=3)
            {
                if (PlayerControl.RezenMaxdistance >= PlayerControl.RezenMindistance)
                    PlayerControl.RezenMaxdistance -= 1;
            }
            else
                PlayerControl.Rezentime -= 1;
        }

        if(PlayerControl.ComboCount >=2)
        {
            StartCoroutine("TextEffect");
        }

        Debug.Log("Count : " + PlayerControl.ComboCount);
        Debug.Log("RezenTime : " + PlayerControl.Rezentime);
        Debug.Log("RezenMaxdistance : " + PlayerControl.RezenMaxdistance);

        countText.text = PlayerControl.Count.ToString("00");
    }
开发者ID:agebreak,项目名称:Unity,代码行数:33,代码来源:ColliderCheck.cs

示例3: EntityBetween

	public void EntityBetween(Vector3 newOrigin, Rigidbody oldTarget){
		float rayDis = Vector3.Distance (newOrigin, oldTarget.transform.position);
		Vector3 rayDir = (oldTarget.transform.position - newOrigin);
		if(Physics.Raycast (newOrigin, rayDir, out rayHit, rayDis)){
			timesHit++;
			if(rayHit.transform.gameObject != oldTarget.gameObject){
				if(rayHit.transform.tag != "Wall" && rayHit.transform.tag != "Cover" && rayHit.transform.tag != "Ground"){
					EntityBetween(rayHit.transform.position, oldTarget);
				}
			}
			else if(rayHit.transform.gameObject == oldTarget.gameObject) {
				GrenadeEffect (oldTarget.gameObject);
				oldTarget.AddExplosionForce (power, explosionPos, radius);
			}
		}
	}
开发者ID:Fahrettin52,项目名称:Game-Lab-2.1,代码行数:16,代码来源:FragGrenades.cs

示例4: ApplyForceToTarget

        void ApplyForceToTarget(Vector3 contactPoint, Rigidbody rb)
        {

            if ( rb.GetComponent<NavMeshAgent>() != null)
                rb.GetComponent<NavMeshAgent>().enabled = false;

            rb.isKinematic = false;

            if ( rb.CompareTag("Enemy") )
            {
                //rb.GetComponent<Rigidbody>().isKinematic = false;
                explosionPower = explosionPower * 10;
            }
              
            rb.AddExplosionForce(explosionPower, contactPoint, blastRadius, .5f, ForceMode.Impulse);
            //Vector3 direction = rb.transform.position - transform.position;
            //rb.AddForceAtPosition(direction.normalized, contactPoint, ForceMode.Impulse);

            if ( rb.CompareTag("Enemy") )
            {
                Destroy(rb.gameObject, destroyTime);
            }
        }
开发者ID:jeffreyyankey,项目名称:TheEnchantedForest_prototype,代码行数:23,代码来源:ShotgunDamage.cs

示例5: OnCollisionEnter

    void OnCollisionEnter(Collision other)
    {
        if(other.gameObject.tag == "Ball")
        {
            score.AddScore(50);
        }
        else if (other.gameObject.tag == "MultiBall")
        {
            score.AddScore(50);
        }

        foreach (Collider col in Physics.OverlapSphere(transform.position, _forceRadius))
        {
            if (col.name == "PlayerBall")
            {
                _colRigid = col.GetComponent<Rigidbody>();
                _colRigid.AddExplosionForce(force, transform.position, _forceRadius);
            }
        }

        Instantiate(explosion, other.transform.position, other.transform.rotation);
        RemoveParticle();
    }
开发者ID:Jprummel,项目名称:Pinball3D,代码行数:23,代码来源:Bumpers.cs

示例6: ApplyForce

 /// <summary>
 /// Applies the force to the specified rigidbody
 /// </summary>
 /// <param name="body">Body receiving the force</param>
 public override void ApplyForce(Rigidbody body) {
   body.AddExplosionForce(Amount, ExplosionOrigin.position, ExplosionRadius, UpwardsModifier,
                          ForceMode.Impulse);
 }
开发者ID:2954722256,项目名称:gvr-unity-sdk,代码行数:8,代码来源:RandomExplosionForce.cs

示例7: AoEHit

 // The AoE effect on game objects
 protected override void AoEHit(Rigidbody obj)
 {
     obj.AddExplosionForce(400f, position, radius);
 }
开发者ID:judah4,项目名称:battle-of-mages,代码行数:5,代码来源:AoEPush.cs

示例8: addForce

 public void addForce(Rigidbody rbody)
 {
     rbody.AddExplosionForce(Force,Position,Radius);
 }
开发者ID:HuvaaKoodia,项目名称:SummerProject2013,代码行数:4,代码来源:Notifications.cs

示例9: Add

 public void Add(Rigidbody target, Vector3 pos)
 {
     target.AddExplosionForce(force, pos, radius, upwardsModifier, mode);
 }
开发者ID:negimochi,项目名称:EchoHiker,代码行数:4,代码来源:TorpedoCollider.cs

示例10: Explode

    /// <summary>
    /// Metodo responsavel por verificar se é necessário explodir e executar a explosao
    /// </summary>
    public virtual void Explode(bool forceExplosion)
    {
        if (_armed && _timeToExplode < Time.time || forceExplosion)
        {
            // Toca o som de explosao

            // Apresenta particulas de explosao
            if (ExplosionParticlePrefab != null)
            {
                GameObject explosionParticle = GameObject.Instantiate(ExplosionParticlePrefab);
                explosionParticle.transform.position = transform.position;
                GameObject.Destroy(explosionParticle, 5f);
            }

            ApplicationModel.Instance.ShakeCamera();

            // Verifica as colisoes
            int _hits = Physics.OverlapSphereNonAlloc(transform.position, ExplosionRadius, _colliders, AffectedLayer);

            if (_hits > 0)
            {
                for (int i = 0; i < _hits; i++)
                {
                    // Recupera os componentes
                    _affectedCharacter = _colliders[i].GetComponent<BaseEnemy>();
                    _affectedRigidBody = _colliders[i].attachedRigidbody;

                    if (_affectedCharacter != null)
                    {
                        // Aplica dano se for personagem
						_affectedCharacter.ApplyDamage(ThrownByCharacter, ENUMERATORS.Combat.DamageType.Melee, ENUMERATORS.Player.PlayerClass.UNDEFINED ,ExplosionDamage);
                    }

                    if (_affectedRigidBody != null)
                    {
                        // Aplica a forca de explosao nos rigidbodys
                        _affectedRigidBody.AddExplosionForce(ExplosionForce, transform.position + Vector3.up * ExplosionYOffSet, ExplosionRadius);
                        _affectedRigidBody.AddForce(Vector3.up * ExplosionForce);
                    }
                }
            }

            ReturnToPool();
        }
    }
开发者ID:GroupByStudios,项目名称:TDS_Gauss,代码行数:48,代码来源:GranadeBase.cs

示例11: ApplyKillForce

 public override void ApplyKillForce(Rigidbody rigidbody)
 {
     rigidbody.AddExplosionForce(Force, Position, Radius, 1f, ForceMode.Impulse);
 }
开发者ID:bodedoctor,项目名称:onslaught,代码行数:4,代码来源:ExplosionKillForce.cs


注:本文中的UnityEngine.Rigidbody.AddExplosionForce方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。