コード例 #1
0
 public virtual bool Shoot()
 {
     if (reloadTimer.timeRemaining <= 0)
     {
         reloadTimer.Reset();
         reloadTimer.Start();
         if (bulletPrefab != null)
         {
             Bullet  bullet          = ObjectPool.instance.SpawnComponent <Bullet>(bulletPrefab.prefabIndex, shootTrs.position, shootTrs.rotation);
             Vector3 velocity        = PhysicsUtilities.GetVelocity(previousShootTrsPosition, shootTrs.position, deltaTime);
             Vector3 angularVelocity = PhysicsUtilities.GetAngularVelocity(previousShootTrsRotation, shootTrs.rotation, deltaTime);
             bullet.rigid.velocity = shootTrs.forward * shootSpeed + PhysicsUtilities.GetPointVelocity(velocity, angularVelocity, Vector3.zero);
             Physics.IgnoreCollision(bullet.collider, collider, true);
             bullet.shootingGun      = this;
             bullet.collider.enabled = true;
         }
         return(true);
     }
     return(false);
 }