Hey developers, quick question on how id make a part follow the player on one axis. like a turret. only moves side to side not up down, if you get what i mean. well more like 2 axes if i say it like that but you get what im saying
Id like it to also be global lol so everyone sees whos its facing
remove the axis you don’t want when doing your calculation. for example if you want a turret to only rotate on the y axis, then use CFrame.lookAt but make sure the y difference between the points is always zero:
By isolating the ‘Y’ component of the target position (I.E. the player), you obtain a sort of “virtual” position for the turret to point assuming the turret is constrained along one of the coordinate planes.
Yes this is accurate. It’s easy to do along an axis because you can just subtract that axis to “flatten” it. You can do it on any arbitrary direction too, but it requires using the dot product to find the distance-to-plane of the points and subtracting that times the axis instead.