Am i dumb or just not seeing something?

I have an “enemy” that when im in range, it chases me then attacks me, by shooting projectiles towards me, or atleast its supposed to.

Here is a streamable link for the video showing what currently happens: 2ovjbx

Here is the function inside the enemies shooting script.

ive been at this for like 2 days now, i cant figure out what im doing wrong. The projectile’s rotation is set to 0 in the prefab thing, ive tried pretty much everything i can think of.

YOU BLIND IDIOT!!

just kidding!

You’re not dumb. Unity is very complicated and quirky and you’ll still do silly things even when you’ve been using it for years.

The issue is that you’re spawning a rigidbody inside another object and it’s messing with the AddForce direction.

Instead do this:

Rigidbody rb=Instantiate(projectile,transform.position+transform.forward,Quaternion.identity).GetComponent<Rigidbody>();

Thanks bud, it worked like a dream!!