I’ve been able to figure out how to shoot it forward, but I can’t rotate it so that for example, if I were to shoot an arrow, the tip won’t point away from the character. I basically just want the projectile to point where it is travelling.
My current code:
clone = Instantiate(projectile, cam.transform.position, projectile.transform.rotation);
Vector3 camDir = transform.forward;
clone.GetComponent<Rigidbody>().AddRelativeForce(camDir * projectileSpeed);
Projectile is the prefab I’m instantiating, cam is the main fps camera and projectileSpeed is the speed the bullet travels at. Everything else should be pretty self explanatory.
If there is any better, easier or more efficient way to do what I’ve done above, please don’t hesitate to tell me. Any help is appreciated!