Cannon Rotation & Movement

Hey devs, I am making a cannon for a little side project to learn more about CFrame manipulation.

Problem is, I don’t know how to make the cannon rotate on two axis at the same time as allowing it to move along rail tracks. Here is an image showing what I mean:

So far I have tried using TweenService with WeldConstraints but I think it would break when the cannon moves along the rails. Another solution I tried was using BodyGyro to rotate the cannon, but I have absolutely no idea how to use that and I feel like it is on the wrong track anyway.

Any ideas on how to do this would be greatly appreciated!

Yep, I made a resource just for this type of situation check it out. The example project in the GitHub has an example of 2 axis rotation, one on the horizontal axis making it look up and down, and one of the vertical axis making it yaw left and right.

I believe you can use the same concept and apply the CFrames of the project to bodygyro but honestly it’s a pain to setup the model such that it doesn’t collide with itself so yeah the Motor6D approach was used.

1 Like

Thanks, I will check it out and mark your answer as a solution once I am done