How do you change the position of a Raycast?

I have a shooting script on my player that it stupposed to delete the enemy once it hits them, identifying them by tag. I ran debug.draw to find that my Raycast was positioned at the bottom of my guys feet, shooting only the ground. Even when i jumped it wouldnt say it shot the other player.

I asked another question on how to find out where it was shooting (see here for info on problem and shooting script) Where does a Raycast come from? - Unity Answers

I was told that the Raycast wont collide with a collider that it is inside of. Does this mean that when i shoot the other player (Clone of myself) that it wont collide with them, if they are tagged the same? Is there any way for me to move the Raycast in front of me so im not only shooting the terrain?

Thanks in advance for any help!

You can change the starting position of the raycast by adding a Vector3 to transform.position in the first argument of Physics.Raycast. So if your original raycast looked like this:

Physics.Raycast(transform.position, transform.forward);

You could change it to look like this:

Physics.Raycast(transform.position + new Vector3(0f, 1.5f, 0f), transform.forward);

Or better yet, instead of hardcoding the new Vector3, you could just declare a var at the top of the script that could be edited in the inspector. It would then be easy to play with the x, y, and z offsets to find a raycast starting position that fits your needs best.

Also, the raycast will only ignore the collider it starts inside of. It doesn’t matter that the enemy is a clone of the player or that it’s tagged the same.