コード例 #1
0
ファイル: Satellite.cs プロジェクト: 517752548/Planetaria
 public void OnTriggerEnter(Collider collider)
 {
     if (!dead) // There's technically a small bug here, where the player can collide with debris that has already collided (with a projectile) - wraparound shots are basically impossible, so that would be for a shot on the ~ same frame
     {
         die();
         Debris debris = collider.GetComponent <Debris>();
         debris.destroy_asteroid(); // should not assign points, since the player died.
     }
 }
コード例 #2
0
        // while I do like the idea of raycasting in update, that would require PlanetariaColliders or hacking my current raycast implementation, so true-to-original it is
        // Also, raycasting would be broken with relative projectile velocities

        public void OnTriggerEnter(Collider collider)
        {
            if (!has_collided) // make sure one projectile doesn't collide with 2+ debris.
            {
                Debris debris = collider.GetComponent <Debris>();
                if (debris.destroy_asteroid()) // make sure two projectiles don't collide with the same debris (wasting one of them).
                {
                    PlanetariaGameObject.Destroy(this.gameObject);
                    has_collided = true;
                }
            }
        }
コード例 #3
0
ファイル: Projectile.cs プロジェクト: mattrdowney/planetaria
        // while I do like the idea of raycasting in update, that would require PlanetariaColliders or hacking my current raycast implementation, so true-to-original it is
        // Also, raycasting would be broken with relative projectile velocities

        public void OnTriggerEnter(Collider collider)
        {
            if (!has_collided) // make sure one projectile doesn't collide with 2+ debris.
            {
                Debris debris = collider.GetComponent <Debris>();
                if (debris.destroy_asteroid()) // make sure two projectiles don't collide with the same debris (wasting one of them).
                {
                    //PlanetariaGameObject.Destroy(this.gameObject); -- the bullets are reused (as a form of object pooling)
                    has_collided            = true;
                    mesh_renderer.enabled   = false;
                    sphere_collider.enabled = false;
                }
            }
        }