Direction from two objects

Hi,
I’m making an FPS and when I shoot I instantiate a bullet.
I also cast a ray to get the direction I want to send the bullet. The problem I’m having is that when I hit something, it sends the bullet too high so it doesn’t hit the target.

Here’s the code:

//Aim Position
        Vector3 aimPos;

        //Cast ray
        RaycastHit hit;
        if(Physics.Raycast(mainCam.transform.position, mainCam.transform.forward, out hit, 50))
        {
            print(hit.transform.name);
            aimPos = hit.point;
        }
        else
        {
            aimPos = mainCam.transform.position + mainCam.transform.forward * 50;
        }


        //Instantiate activeSpell.spellPrefab;
        GameObject bullet= Instantiate(bulletPrefab, spawnPoint.position, Quaternion.identity);

        //Addforce to spellPrefab
        bullet.GetComponent<Rigidbody>().AddForce((aimPos - transform.position).normalized * Speed);

Is there a problem with my code? Or am I just doing something wrong?

Good day.

You are calculating the bullet direction from

transform.position

and i supose it should be

bullet.transform.position

Bye! >D

Oh of course!! Thank you!