Hello, RbxDev
I have a vector math problem that I have been struggling for a while to solve, a quite ‘simple’ problem, really.
The problem:
I’m trying to make AI gun turrets that aim at objects. Simple, really, I just need the turret’s main part to be looking directly at the object to shoot. This is done by modifying a singular weld from the base to the top of the turret.
The complications:
1.) The base of the turret is welded to a large ship, essentially a part that will cause the entire turret to rotate freely and randomly about the Y-axis. In addition, it may start with an initial offset relative to this part (for example, the base may be facing forwards or backwards according to the ship.)
2.) The turret is limited in its rotation by a given amount of degrees to either side from pointing directly forward on its base. If it is past this rotation limit, it will simply sit at this limit without shooting until the target comes back into its limit.
What I have done:
I’ve got the up and down (the easy part) working just fine. I also have a function that gets the nearest enemy ship and its angle relative to the ship that the turret is attached to. Attempting to put these two together has been incredibly frustrating, as the turrets sometimes work great and sometimes shoot in the opposite direction of where they should.
If anyone can fix these aiming inaccuracies (before I do with my random guesswork) or point me toward how to rework it entirely into working order, I will pay:
-35k robux, or up to 10k more if done in a timely manner.
-Credit given in any reasonable manner that you ask (name in description, ingame benefits, etc)
Message me here, on Roblox, or on Skype (MyNameIsNotPa) if you would like to help.