Top-down (3D) rotate arrow projectile towards shoot position

Hello there, I’m working on a top-down game in which a player can shoot an arrow projectile which moves in the direction of the mouse. I’ve set the arrow object to have a rigidbody and rotated the object to be facing forward (pic A).

I’m attempting to rotate the projectile along it’s Y-axis (as that’s the one I have setup to rotate around the players movement directions) so the arrow will point towards the movement direction rather than how it is right now (pic B).


using UnityEngine;
using System.Collections;

public class Player: MonoBehaviour {
    public GameObject arrowProjectile;

    void Start()


    void Update()
        if (Input.GetButtonDown("Ability_1"))
            Vector3 myPos = transform.position;
            float dist = Camera.main.transform.position.y - myPos.y;
            float x = Input.mousePosition.x;
            float y = Input.mousePosition.y;
            Vector3 dir = Camera.main.ScreenToWorldPoint(new Vector3(x, y, dist)) - myPos;
            GameObject projectile = (GameObject) Instantiate(arrowProjectile);
            Rigidbody rigidbody = projectile.GetComponent<Rigidbody>();
            rigidbody.velocity = dir.normalized * 5.0f;

            Vector3.RotateTowards(projectile.transform.forward, dir, 5.0f * Time.deltaTime, 0.0f);

Pic A:

Pic B:

take a look at “transform.TransformDirection()” and “Transform.TransformPoint” and also Transform.InverseTransformDirection .
you can find further details at unity script refence docs.