Basically I have some guns, you can switch between them, and shoot them, and I have them creating a raycast down the barrel so that when its done it will render a reticle at 5 meters out or on the object in front of the gun, (It’s a third person shooter, thus a reticle in the middle of the screen simply will not do.) All in all it’s going quite well, but I hit a snag, I have a model (just a simple ring) and I want to have it be spawned wherever the ray ends, be that an object or just floating in the air at the end of the ray.
the script for this part of the guns pretty simple:
void Reticle ()
{
Vector3 fwd = BulletSpawn.transform.TransformDirection(Vector3.up);
if (Physics.Raycast(transform.position, fwd, 5))
{
print("There is something in front of the object!");
}
Debug.DrawRay(BulletSpawn.transform.position, fwd, Color.green);
}
If you want the hole script I can pull that from my files. Any thoughts guys?