本文整理汇总了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);
}
示例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");
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
示例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);
}
示例7: AoEHit
// The AoE effect on game objects
protected override void AoEHit(Rigidbody obj)
{
obj.AddExplosionForce(400f, position, radius);
}
示例8: addForce
public void addForce(Rigidbody rbody)
{
rbody.AddExplosionForce(Force,Position,Radius);
}
示例9: Add
public void Add(Rigidbody target, Vector3 pos)
{
target.AddExplosionForce(force, pos, radius, upwardsModifier, mode);
}
示例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();
}
}
示例11: ApplyKillForce
public override void ApplyKillForce(Rigidbody rigidbody)
{
rigidbody.AddExplosionForce(Force, Position, Radius, 1f, ForceMode.Impulse);
}