So I was trying to make a very simple bullet which literally just casts a line from the tip of the gun forward the same amount as a raycast. I’m thinking my issue may have something to do with the fact that the accessed line renderer isn’t on the same object as the script but I did try this before and it seemed to work. I would put the line renderer on the same object but it’s already in use by another script on the object. I’ll put the code I think is relevant here:
RaycastHit hit;
Ray isGrounded = new ray (transform.position, cam.forward);
if (Physics.RayCast (isGrounded, out hit, reach)){
line.SetPosition(1, pistol.transform.position);
line.SetPosition(2, hit.point);
}}
I understand the line should only be drawn when there is a raycast hit, but I have also set up the print function so I know when it should be called. I’m really lost with this ass it worked fine with practically identical code on the other script so I figure it must be something to do with the line renderer not actually being attached to the player’s object. Please help.