VR模拟枪支打靶,消灭鬼怪,换弹以及上弦等等硬核枪支操作。 使用HTCVive设备,开启SteamVR进行游玩。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.1 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityStandardAssets.Effects
{
public class ExplosionPhysicsForce : MonoBehaviour
{
public float explosionForce = 4;
private IEnumerator Start()
{
// wait one frame because some explosions instantiate debris which should then
// be pushed by physics force
yield return null;
float multiplier = GetComponent<ParticleSystemMultiplier>().multiplier;
float r = 10*multiplier;
var cols = Physics.OverlapSphere(transform.position, r);
var rigidbodies = new List<Rigidbody>();
foreach (var col in cols)
{
if (col.attachedRigidbody != null && !rigidbodies.Contains(col.attachedRigidbody))
{
rigidbodies.Add(col.attachedRigidbody);
}
}
foreach (var rb in rigidbodies)
{
rb.AddExplosionForce(explosionForce*multiplier, transform.position, r, 1*multiplier, ForceMode.Impulse);
}
}
}
}