コード例 #1
0
        /// <summary> Modifies terrain height in given point. </summary>
        public void ModifyTerrain(Vector3 center, bool upMode)
        {
            const float radius         = 5;
            var         forceDirection = upMode ? new Vector3(0, 1, 0) : new Vector3(0, -1, 0);

            BehaviourHelper.Modify(new MeshQuery()
            {
                Epicenter       = center,
                Radius          = radius,
                ForceDirection  = forceDirection,
                OffsetThreshold = 1,
                GetForceChange  = distance => 2 / ((float)Math.Pow(distance + 1, 1.67))
            });
        }
コード例 #2
0
            private void OnCollisionEnter(Collision collision)
            {
                if (_isDestroyed)
                {
                    return;
                }

                ContactPoint contact = collision.contacts[0];

                BehaviourHelper.Modify(new MeshQuery()
                {
                    Epicenter       = contact.point,
                    Radius          = ExplosionRadius,
                    ForceDirection  = _direction,
                    OffsetThreshold = 2f,
                    GetForceChange  = distance => 2 / ((float)Math.Pow(distance + 1, 1.67))
                });
                Destroy(gameObject);
                _isDestroyed = true;
            }