木蘑菇
This commit is contained in:
parent
861ba21b13
commit
f1d8219300
@ -401,4 +401,40 @@ public class Attack : MonoBehaviour
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void ShanXingAttack()//扇形散射
|
||||
{
|
||||
if (bulletPrefab == null)
|
||||
{
|
||||
Debug.LogError("子弹预制体为空");
|
||||
return;
|
||||
}
|
||||
|
||||
float halfAngle = Angle / 2f; // 半个散射角度范围
|
||||
float angleStep = Angle / (BulletNumber - 1); // 每个子弹之间的角度间隔
|
||||
|
||||
for (int i = 0; i < BulletNumber; i++)
|
||||
{
|
||||
// 改变子弹方向,根据角色自身的攻击范围来计算
|
||||
GameObject BulletGamobj = GameObject.Instantiate(bulletPrefab, this.transform.root);
|
||||
Bullet bulletScript = BulletGamobj.GetComponent<Bullet>();
|
||||
|
||||
bulletScript.role = role;
|
||||
bulletScript.attackObj = this;
|
||||
bulletScript.bulletData.BulletSpeed *= (1 + roleBulletSpeedAdd);
|
||||
bulletScript.Target = Target;
|
||||
|
||||
// 计算当前子弹的发射角度
|
||||
float currentAngle = -halfAngle + angleStep * i; // 当前子弹的偏移角度
|
||||
|
||||
// 使用偏移角度调整子弹的发射方向
|
||||
Vector3 scatterDirection = Quaternion.Euler(0, 0, currentAngle) * direction; // 在当前方向上添加旋转
|
||||
|
||||
BulletGamobj.transform.up = scatterDirection;
|
||||
BulletGamobj.transform.position = BulletStartPos.position;
|
||||
bulltes.Add(BulletGamobj);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user