Hi everyone! So I’ve noticed that in Survival Shooter learn series from Unity when you shoot, line renderer and ray are bit off from mouse position. It looks like this:
I’ve tried to correct the shooting so the ray is crossing mouse pointer but unfortunately, I couldn’t do it after trying everything I could think of. I tried to use “transform.LookAt(point where the ray is hitting the floor plane)” so that the end of the gun barrel object is always looking at the mouse pointer so I could just use “transform.position & transform.forward” when doing the ray cast. It’s still off from the mouse pointer. This is the code for the shooting: http://pastebin.com/raw/QhQEjGmv
Can someone please help me to fix this problem?
I've found the problem. Main camera was rotated around X axis for 30 degrees. When I set it's rotation to 90 degrees so it's top down, I can see no offset. All good. But when I set back to any rotation rather than 90, the offset is back. I even tried to see if ray.direction is changing when switching rotations of the cameras, it's the same so I have no idea why is this happening.
– Dominik523