I need help with accurately aiming a gun where the barrel does not aim through the center of rotation.
What are some ways I can accurately aim the barrel at the red part while still rotating the barrel from the green dot?
I need help with accurately aiming a gun where the barrel does not aim through the center of rotation.
What are some ways I can accurately aim the barrel at the red part while still rotating the barrel from the green dot?
Nevermind I figured it out. https://gyazo.com/4fafb9be121ba7476843f97c24a1b990
When you’re posting a statement saying that you fixed something (likely on your own) it is good practice to describe what brought you to the fix and specifically what you changed.
This helps users in the future that are looking for a solution to the same problem. Instead of finding helpful advice on this post they’ll get a gif of the working product.
Sorry I was in a hurry. Here’s the steps I used.
Using a regular CFrame.new(Center of Rotation, Target) will set the turret pointing towards the Target in the configuration above with the Barrel parallel to the target.
In my case the Barrel was at a fixed height above the CoR. This height can be used as the radius of a circle where the barrel will always be tangent to.
If we measure the distance from the Target to the CoR and we know the target is in-line with the CoR we can use basic trigonometry to solve for the Angle of Depression
tan(Height / Distance)