I can’t get the arrows to stick, they collide properly with everything. I just can’t seem to figure out how to get it to stick now.
There are two scripts one is for managing the arrows and the other for firing.
ArrowManagerScript
private void Fire(float strDist)
{
currentArrow.transform.parent = null; //detach arrow from all parants
Rigidbody r = currentArrow.GetComponent<Rigidbody>();
r.velocity = currentArrow.transform.forward * arrowPowerMultiplyer * strDist;
r.useGravity = true;
r.isKinematic = false;
stringAttachPoint.transform.localPosition = stringStartPoint.transform.localPosition; //rest string
currentArrow.GetComponent<Arrow>().Fired();
currentArrow.GetComponent<Collider>().isTrigger = false;
Destroy(currentArrow, 4f);
currentArrow = null;
isAttached = false;
}
ArrowScript
public bool isFired = false;
// Update is called once per frame
void Update()
{
if (isFired)
{
transform.LookAt(transform.position + transform.GetComponent<Rigidbody>().velocity);// make arrow lookat where it is going like an arrow
}
}
public void Fired()
{
isFired = true;
}
private void OnTriggerStay(Collider col)
{
if (SteamVR_Actions._default.GrabPinch.GetStateDown(SteamVR_Input_Sources.RightHand)) //if trigger pulled
{
ArrowManager.Instance.AttachArrowToBow(); //attach arrow to bow
}
}
I am hoping to get the arrow to stick, Also the arrow script is attached to an arrow prefab and the arrowmanager is attached to the SteamVr rightHand