Ready for Testing 1

This commit is contained in:
Toomas Tamm
2021-04-11 20:50:24 +03:00
parent 76922a8b27
commit 90563e776a
16 changed files with 429 additions and 846 deletions

View File

@@ -13,15 +13,20 @@ namespace Bow
public float speed = 2000.0f;
public Transform tip = null;
public float maxLifetimeAfterShot = 60f;
private bool _inAir = false;
private Vector3 _lastPosition = Vector3.zero;
private Rigidbody _rigidbody = null;
private float _timeToDestroyOn;
protected override void Awake()
{
base.Awake();
_rigidbody = GetComponent<Rigidbody>();
_timeToDestroyOn = float.MaxValue;
}
private void FixedUpdate()
@@ -29,6 +34,11 @@ namespace Bow
if (!_inAir) return;
CheckForCollision();
_lastPosition = tip.position;
if (_timeToDestroyOn <= Time.time)
{
Destroy(gameObject);
}
}
private void CheckForCollision()
@@ -75,6 +85,7 @@ namespace Bow
Vector3 force = transform.forward * (power * speed);
_rigidbody.AddForce(force);
_timeToDestroyOn = Time.time + maxLifetimeAfterShot;
}
private IEnumerator RotateWithVelocity()