- Home /
Question by
vahidhusyn · May 11 at 12:45 PM ·
raycastquaternionshootingrigidbody.addforce
Arrow not shooting the in right orientation
I'm trying to shoot arrows in the direction the camera is facing.
The arrows however are shooting in the wrong orientation with their arrowhead to the left direction. The direction of the throw is aligned but the arrows are not going arrowhead-first. Arrows are children of the main camera and the script is sitting on the bow.
GameObject projectile = Instantiate(Arrow, attackPoint.position, cam.rotation);
Rigidbody projectileRb = projectile.GetComponent<Rigidbody>();
Vector3 forceDirection = cam.transform.forward;
RaycastHit hit;
if(Physics.Raycast(cam.position, cam.forward, out hit, range))
{
forceDirection = (hit.point - attackPoint.position).normalized;
}
Vector3 forceToAdd = forceDirection * shootForce + transform.up * shootUpwardForce;
projectileRb.AddForce(forceToAdd, ForceMode.Impulse);
Comment