1
This commit is contained in:
@@ -18,8 +18,8 @@ namespace BITFALL
|
||||
public record InstanceBullet : SpawnBullet
|
||||
{
|
||||
public Vector3 currentPos;
|
||||
public float InitialForce;
|
||||
public float currentSpeed = 64;
|
||||
public float ElapsedTime;
|
||||
public BITBullet model;
|
||||
}
|
||||
[Serializable]
|
||||
@@ -43,7 +43,7 @@ namespace BITFALL
|
||||
private IDamageService damageService;
|
||||
|
||||
[Header(Constant.Header.Settings)]
|
||||
public UnityPool<BITBullet> pool = new();
|
||||
[SerializeField] private UnityPool<BITBullet> pool = new();
|
||||
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
private readonly List<InstanceBullet> instances = new();
|
||||
@@ -77,9 +77,15 @@ namespace BITFALL
|
||||
}
|
||||
else
|
||||
{
|
||||
// 计算子弹的下坠距离
|
||||
float distance = 0.5f * Physics.gravity.y * bullet.ElapsedTime * bullet.ElapsedTime;
|
||||
|
||||
bullet.currentSpeed -= bullet.startSpeed * Time.fixedDeltaTime;
|
||||
bullet.currentPos += (Vector3)bullet.forward * (bullet.currentSpeed * Time.fixedDeltaTime);
|
||||
bullet.currentPos += Vector3.up * distance;
|
||||
bullet.model.transform.position = bullet.currentPos;
|
||||
|
||||
bullet.ElapsedTime += Time.fixedDeltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +137,7 @@ namespace BITFALL
|
||||
(null, null) => null,
|
||||
(null, not null) => damagable?.Rigidbody,
|
||||
(not null, null) => raycastHit.rigidbody,
|
||||
(not null, not null) => raycastHit.rigidbody,
|
||||
(not null, not null) => damagable?.Rigidbody,
|
||||
};
|
||||
if (_rigidbody is not null && _rigidbody.gameObject.layer is not 0)
|
||||
{
|
||||
@@ -154,8 +160,12 @@ namespace BITFALL
|
||||
forward = raycastHit.normal,
|
||||
};
|
||||
var vfx = DI.Get<VFXService>().Spawn(location, tags.ToArray());
|
||||
var constraint = vfx.gameObject.AddComponent<ParentConstraint>();
|
||||
var constraint = vfx.gameObject.GetOrAddComponent<ParentConstraint>();
|
||||
var sourceTransform = raycastHit.transform;
|
||||
while (constraint.sourceCount>0)
|
||||
{
|
||||
constraint.RemoveSource(0);
|
||||
}
|
||||
constraint.AddSource(new ConstraintSource()
|
||||
{
|
||||
sourceTransform = sourceTransform,
|
||||
|
Reference in New Issue
Block a user