Helo!
I have a problem with shooting with raycast:
This is the code what i currently using
aimEndPoint:
and this is the result when i aimed to the stone:
And also I tried to change the raycast direction to “Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0f));”, but its only good when i shooting from hips.
Probably the problem is the weapon rotating differently from the camera:
The top red cursor is centered and the weapon is not towarding to it.
Thanks for the help!
Send a raycast out from the camera to find out where your player will expect their bullets to land. Then using LookAt to rotate the gun so that it’s rotated to be pointed at the same point.
Sadly that would not solve the problem.
Its hard to explain, so I uploaded the game: https://drive.google.com/file/d/1HefcpOPx9ZPP0lHAh0npo3RIhvTLErvL/view?usp=sharing
When you shoot a line appear, which shows the Raycast, the blue image is the center of the screen
I tried to change the code to this: https://pastebin.com/YZq0GDpZ
This is working perfectly with hips shooting, but when I aiming with iron sight, its completly wrong.
