@@ -37,11 +37,29 @@ public class Arrow : MonoBehaviour
3737
3838 private GameObject scaleParentObject = null ;
3939
40+ private float initialMass ;
41+ private float initialDrag ;
42+ private float initialAngularDrag ;
43+ private RigidbodyInterpolation initialInterpolation ;
44+ private CollisionDetectionMode initialCollisionDetection ;
45+ private bool initialUseGravity ;
4046
41- //-------------------------------------------------
42- void Start ( )
43- {
44- Physics . IgnoreCollision ( shaftRB . GetComponent < Collider > ( ) , Player . instance . headCollider ) ;
47+
48+ private void Awake ( )
49+ {
50+ initialMass = shaftRB . mass ;
51+ initialDrag = shaftRB . drag ;
52+ initialAngularDrag = shaftRB . angularDrag ;
53+ initialInterpolation = shaftRB . interpolation ;
54+ initialCollisionDetection = shaftRB . collisionDetectionMode ;
55+ initialUseGravity = shaftRB . useGravity ;
56+ Destroy ( this . GetComponent < Rigidbody > ( ) ) ;
57+ }
58+
59+ //-------------------------------------------------
60+ void Start ( )
61+ {
62+ Physics . IgnoreCollision ( this . GetComponent < Collider > ( ) , Player . instance . headCollider ) ;
4563 }
4664
4765
@@ -52,17 +70,35 @@ void FixedUpdate()
5270 {
5371 prevPosition = transform . position ;
5472 prevRotation = transform . rotation ;
55- prevVelocity = GetComponent < Rigidbody > ( ) . velocity ;
73+ prevVelocity = shaftRB . velocity ;
5674 prevHeadPosition = arrowHeadRB . transform . position ;
5775 travelledFrames ++ ;
5876 }
5977 }
6078
6179
80+ public void StartRelease ( )
81+ {
82+ Rigidbody rb = this . gameObject . AddComponent < Rigidbody > ( ) ;
83+ rb . isKinematic = true ;
84+ if ( shaftRB == null )
85+ shaftRB = rb ;
86+
87+ shaftRB . mass = initialMass ;
88+ shaftRB . drag = initialDrag ;
89+ shaftRB . angularDrag = initialAngularDrag ;
90+ shaftRB . interpolation = initialInterpolation ;
91+ shaftRB . collisionDetectionMode = initialCollisionDetection ;
92+ shaftRB . useGravity = initialUseGravity ;
93+
94+ arrowHeadRB . GetComponent < FixedJoint > ( ) . connectedBody = rb ;
95+ }
96+
97+
6298 //-------------------------------------------------
6399 public void ArrowReleased ( float inputVelocity )
64- {
65- inFlight = true ;
100+ {
101+ inFlight = true ;
66102 released = true ;
67103
68104 airReleaseSound . Play ( ) ;
0 commit comments