Ready for Testing 1
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user